A linked list is a linear collection of data elements, in which each node points to the next node. Unlike an array, it doesn’t have upper limit and hence extremely useful.
The task is to access value of each node of linked list and reverse them.
Input : 56 87 12 49 35 Output :65 78 21 94 53 Input : 128 87 12433 491 33 Output :821 78 33421 194 33
The task can be accomplished as:
- Linearly traverse each node of the singly linked list.
- Reverse the value of each node.
- Store the reversed value in the current node.
List before reversing individual data item 56 87 12 49 35 List after reversing individual data item 65 78 21 94 53
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.
- Reverse a singly Linked List in groups of given size | Set 3
- Reverse alternate K nodes in a Singly Linked List
- Reverse alternate K nodes in a Singly Linked List - Iterative Solution
- Select a Random Node from a Singly Linked List
- Given only a pointer to a node to be deleted in a singly linked list, how do you delete it?
- Update adjacent nodes if the current node is zero in a Singly Linked List
- Given only a pointer/reference to a node to be deleted in a singly linked list, how do you delete it?
- Recursive selection sort for singly linked list | Swapping node links
- Program to delete all even nodes from a Singly Linked List
- Reverse each word in a linked list node
- Java Program for Reverse a linked list
- Program to reverse a linked list using Stack
- Difference between Singly linked list and Doubly linked list
- Convert singly linked list into circular linked list
- Program for n'th node from the end of a Linked List
- Convert Singly Linked List to XOR Linked List
- Sum of the nodes of a Singly Linked List
- QuickSort on Singly Linked List
- Convert a Singly Linked List to an array
- Circular Singly Linked List | Insertion
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.