Hi. Can you guys help me out with this link list method. The method issuppose to say if a list is in ascendent order or descendent order. I have this right now:
template <typename ListElement>
int List <ListElement>::order()
{
NodePtr temp1;
NodePtr temp2;
temp1 = Head;
temp2 = temp1->Next;
while(temp1 != NULL) {
if(temp1->Info.Age > temp2->Info.Age) {
cout << "Descendent order" << endl;
} else if(temp1->Info.Age < temp2->Info.Age) {
cout << "Ascendent Order" << endl;
} else
cout << "No order" << endl;
temp2 = temp1->Next;
}
return 0;
}
The methods, but when the list is in disorder for example (1,3,5,4) still says is in ascendent order. How could i fix that? Thanks
I know that the loop has to check not only the next node but the whole list, but i cant get that part.