It doesn’t look possible to reverse a simple singly linked list. A simple singly linked list can only be reversed in O(n) time using recursive and iterative methods.
A memory efficient doubly linked list with head and tail pointers can also be reversed in O(1) time by swapping head and tail pointers.
A doubly linked list with head and tail pointers can also be reversed in O(1) time by swapping head and tail pointers. But we would have to traverse the list in forward direction using prev pointer and reverse direction using next pointer which may not be considered valid.
This article is contributed by Abhishek. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Clone a linked list with next and random pointer | Set 1
- Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes
- XOR Linked List – A Memory Efficient Doubly Linked List | Set 1
- Reverse a linked list
- Insertion Sort for Singly Linked List
- Rearrange a Linked List in Zig-Zag fashion | Set-2
- How does Floyd’s slow and fast pointers approach work?
- Flatten a binary tree into linked list
- Move first element to end of a given Linked List
- Hashtables Chaining with Doubly Linked Lists