Technical Interview

Added Recently
Data Structures
Google & Microsoft
C/C++ Questions
Java Interview Questions
Quantitative Problems
Featured Articles
Amazon Interview Question
Compaq Interview Question
Technical Interview
Interview Process
Introduction Questions
Object Oriented
Google Pages
Fundamental Questions
Resume Tips
Contact Us
Submit Question/Answer

 Algorithms Questions


Write a program to reverse a singly linked list

Node* ReverseList( Node ** List )

Node *temp1 = *List;
Node * temp2 = NULL;
Node * temp3 = NULL;

while ( temp1 )
*List = temp1; //set the head to last node
temp2= temp1->pNext; // save the next ptr in temp2
temp1->pNext = temp3; // change next to privous
temp3 = temp1;
temp1 = temp2;

return *List;

More solutions