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

How to reverse singly link list?

683


Is queue fifo or lifo?

634


In what scenario, binary search can be used?

716


What is the order of selection sort?

599


What is the difference between hashmap and arraylist?

687






Which list does not allow duplicates?

658


What is the use of treemap?

677


How will you explain circular linked list?

683


Why do we need sorting algorithms?

665


Are the expressions arr and &arr same for an array of integers?

754


What is bubble sort algorithm?

744


Which is faster hashmap or hashtable?

680


How many sorting are there in data structure?

649


What is stack explain with diagram?

667


What is binary tree and its types?

653