Given pointer to the head node of a linked list, the task is to reverse the linked list. We need to reverse the list by changing links between nodes.
Input : Head of following linked list 1->2->3->4->NULL Output : Linked list should be changed to, 4->3->2->1->NULL Input : Head of following linked list 1->2->3->4->5->NULL Output : Linked list should be changed to, 5->4->3->2->1->NULL Input : NULL Output : NULL Input : 1->NULL Output : 1->NULL
A Simpler and Tail Recursive Method
Please refer complete article on Reverse a linked list for more details!
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.
- C Program to reverse each node value in Singly Linked List
- Program to reverse a linked list using Stack
- 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
- 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
- Check if a linked list is Circular Linked List
- Generate Linked List consisting of maximum difference of squares of pairs of nodes from given Linked List
- 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)
- Can we reverse a linked list in less than O(n)?
- An interesting method to print reverse of a linked list
- Reverse a Linked List according to its Size
- Reverse a sublist of linked list
- Reverse a circular linked list