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

Define disjoint set adt?

537


Is python good for freshers?

502


Are linked lists considered linear or non-linear data structures?

579


State the difference between queues and linked lists?

544


How many sorting techniques are there?

492






How many types of arrays are there?

522


What is the advantage of the heap over a stack?

581


How to fill element (initialize at once) in an array?

549


What is the structure of an array?

464


In tree construction which is the suitable efficient data structure?

555


Which is better hashset or treeset?

497


What is a minimum spanning tree?

558


What is collections singletonlist?

504


How many parts are there in a declaration statement using data structures?

488


Explain the difference between hashset and hashmap?

546