How to reverse a linked list iterative algorithm?



How to reverse a linked list iterative algorithm?..

Answer / Vandana Kanaujia

To reverse a linked list iteratively in an algorithm, follow these steps:
1. Initialize three pointers: prev, curr, and next.
2. Assign the head node as the current node (curr).
3. Set the next pointer of the current node to null.
4. Move the current node to the next node.
5. Change the head of the list to the previous node.
6. Repeat steps 4 and 5 until the current node becomes null.
7. Now, the linked list is reversed.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Structures Interview Questions

What is linear and non linear structure?

1 Answers  


Define splay tree?

1 Answers  


Does treeset allow null values?

1 Answers  


Can we store a string and integer together in an array?

1 Answers  


What is list and types of list?

1 Answers  


Which is faster hashmap or treemap?

1 Answers  


Which process places data at the back of the queue?

1 Answers  


Can you distinguish between ArrayList and Array?

1 Answers   QuestPond,


How many parts are there in a declaration statement?

1 Answers  


What is advantage and disadvantage of linked list?

1 Answers  


Is json a data structure?

1 Answers  


Is pointer a variable in data structure?

1 Answers  


Categories