Vrbo Interview Question

How do you reverse all of the pointers in a singly-linked list?

Interview Answer

Anonymous

Sep 19, 2013

void reverseSLList(Node *head) { Node *tempNode = NULL; Node *tempNext = NULL; while(head != NULL) { tempNode = head; head = head->next; tempNext = head->next; head->next = tempNode; head = tempNext; } head = tempNode; }