Interview Question

Interview(Student Candidate)

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

  list?
Answer

Interview Answer

1 Answer

0

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; }

Anonymous on Sep 18, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.