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
Explain circular linked list?
What are the applications of b-tree?
What is the idea behind splaying?
Are sets sorted?
Different Types of pattern?
Which sorting algorithm is the slowest?
How do I sort hashset?
Why it is important to have aligned addresses? What is the exception generated when there is a misaligned address?
Is treemap thread safe?
What is the best case time complexity of bubble sort?
What is vector and types of vector?
How would you reverse characters of an array without using indexing in the array.
What is sequential search? What is the average number of comparisons in a sequential search?
What is faster array or arraylist?
Why sorting is done?