interview questions and answers

Technical Interview Questions | DataStructure Interview Questions

Home interview questions Programming interview questions DataStructure 
Saturday, 11 February 2012
Main Menu
Home
Online Test
Contest
Search
FAQs
Contact Us
Login
Most Popular Category
JAVA

Microsoft Technologies
ASP, C#, DotNet, ...

Programming
C++, PHP, VB, ...

SAP

Testing

Web Technologies

Polls
Does personal networking help in job search?
 
IT Placement Papers interview questions Programming interview questions DataStructure

This category contains DataStructure Interview Questions and Answers


Reverse a singly linked list.

PDF Print E-mail


//
// iterative version
//
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;
}




Be first to comment this article

Only registered users can write comments.
Please login or register.

 
< Prev

Technical Interview Questions | DataStructure Interview Questions

Top!
Top!
Copyright © 2008 InterviewDuniya.com All Rights Reserved.
Partner Site: Maheshwari Matrimony