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
how to add an item to the beginning of the list?
What are the types of queues?
What are the advantages of bubble sort?
Write a program to reverse a single linked list.
What does isempty() member method determines?
How to reverse a singly linked list?
Define 2-3-4 tree?
Is null a binary search tree?
Can treemap have null values?
What are the advantages of array?
What is default size of hashmap?
Which interfaces are implemented by linkedhashset?
What is the difference between array and stack?
What is a list in data structure?
What is sequential sorting?