Given a doubly-linked list of positive integers. The task is to print the given doubly linked list data in reverse order.
Input: List = 1 <=> 2 <=> 3 <=> 4 <=> 5 Output: 5 4 3 2 1 Input: 10 <=> 20 <=> 30 <=> 40 Output: 40 30 20 10
- Take a pointer to point to head of the doubly linked list.
- Now, start traversing through the linked list till the end.
- After reaching last node, start traversing in backward direction and simultaneously print the node->data.
Below is the implementation of the above approach:
Linked List elements in reverse order : 2 4 8 10
- Print the last k nodes of the linked list in reverse order | Iterative Approaches
- Print the last k nodes of the linked list in reverse order | Recursive approach
- Reverse a Doubly Linked List
- Reverse a Doubly Linked List | Set-2
- Reverse a Doubly linked list using recursion
- Reverse a doubly circular linked list
- Reverse a Doubly Linked List | Set 4 (Swapping Data)
- Reverse a doubly linked list in groups of given size
- Merge two sorted linked lists such that merged list is in reverse order
- Print Reverse a linked list using Stack
- Print reverse of a Linked List without actually reversing
- An interesting method to print reverse of a linked list
- Print reverse of a Linked List without extra space and modifications
- Merge K sorted Doubly Linked List in Sorted Order
- Difference between Singly linked list and Doubly linked list
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.