create an singly linked lists and reverse the lists by
interchanging the links and not the data?

Answer Posted / bharath

I am correcting Vaishali's method here,

We can achive this using following method:
Use three pointers
First is start pointing to first node.
Second is prev pointing to second node
Third is curr pointing to third node.

start->next=NULL;
while(start!=curr)
{
prev->next=start
start=prev;
prev=curr;
curr=curr->next;
}
This reverses the list.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the Advantages and disadvantages of Array?

597


What are the categories of avl rotations?

547


What is nonlinear data?

495


What is storage structure in data structure?

513


How many passes are required in bubble sort?

470






Can we use Generics with the array?

593


Is learning data structures necessary?

463


What is an expression tree?

534


Define in brief an array.

519


What is selection in an algorithm?

497


What is the difference between collections class vs collections interface?

536


Which is the parent class of abstractqueue class?

512


Which is better array or linked list?

490


What happens in insertion sort?

495


Are duplicates allowed in list?

495