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 is ds tree?

512


What is the non linear data structure?

473


What is data structure definition?

489


How do you insert a new item in a binary search tree?

554


What is stack push?

456






Why is quicksort not stable?

449


Is a hash table a map?

481


Can we change the size of an array at run time?

528


Does hashmap sort automatically?

557


Reverse a linked list from the middle.

534


How many types of data structures are there?

525


Define static data structures?

527


What is subtree?

526


What is structured data with example?

478


What is array simple?

500