(10%)
Determine whether the following code is correct or not. If it is
correct, predict its output. If it is incorrect, point out the
mistake(s).
// Traverse a linked-list
#include <iostream>
struct ListElement
{
int value;
ListElement* pNext;
};
void Print(ListElement* p)
{
while (p != NULL)
{
std::cout << p->value;
p = p->pNext;
}
std::cout << std::endl;
}
int main()
{
ListElement LE1 = { 1, NULL };
ListElement LE2 = { 4, NULL };
ListElement LE3 = { 3, NULL };
ListElement LE4 = { 2, NULL };
LE1.pNext = &LE4;
LE3.pNext = &LE2;
LE4.pNext = &LE3;
Print(&LE1);
return 0;
}