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 reverse singly link list?
Is queue fifo or lifo?
In what scenario, binary search can be used?
What is the order of selection sort?
What is the difference between hashmap and arraylist?
Which list does not allow duplicates?
What is the use of treemap?
How will you explain circular linked list?
Why do we need sorting algorithms?
Are the expressions arr and &arr same for an array of integers?
What is bubble sort algorithm?
Which is faster hashmap or hashtable?
How many sorting are there in data structure?
What is stack explain with diagram?
What is binary tree and its types?