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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Sum and Product of all the nodes which are less than K in the linked list
- Delete all the nodes from the list which are less than K
- XOR Linked List - A Memory Efficient Doubly Linked List | Set 1
- XOR Linked List – A Memory Efficient Doubly Linked List | Set 2
- Merge a linked list into another linked list at alternate positions
- Check if a linked list is Circular Linked List
- Convert singly linked list into circular linked list
- Difference between Singly linked list and Doubly linked list
- Convert Singly Linked List to XOR Linked List
- Create new linked list from two given linked list with greater element at each node
- Reverse a linked list
- Print reverse of a Linked List without actually reversing
- Reverse a Doubly Linked List
- Reverse a Linked List in groups of given size | Set 1
- Reverse alternate K nodes in a Singly Linked List
- Given a linked list, reverse alternate nodes and append at the end
- Merge two sorted linked lists such that merged list is in reverse order
- Iteratively Reverse a linked list using only 2 pointers (An Interesting Method)
- An interesting method to print reverse of a linked list
- Reverse a Linked List in groups of given size | Set 2