Given a doubly-linked list, find the largest node in the doubly linked list.
Input: 10->8->4->23->67->88 Largest node is: 88 Output: 88 Input : 34->2->78->18->120->39->7 Largest node is: 120 Output :120
Approach Used :
1. Initialize the temp and max pointer to head nodes.
2. Traverse the whole list.
3. if temp’s data is greater than max’s data, then put max = temp.
4. move on next node .
Time Complexity: O(n)
Auxiliary Space : O(1)
- Delete a node in a Doubly Linked List
- Delete a Doubly Linked List node at a given position
- Find pairs with given sum in doubly linked list
- Program to find size of Doubly Linked List
- Find pairs with given product in a sorted Doubly Linked List
- Find first node of loop in a linked list
- Find modular node in a linked list
- Find the balanced node in a Linked List
- Find the fractional (or n/k - th) node in linked list
- Find kth node from Middle towards Head of a Linked List
- Recursive Approach to find nth node from the end in the linked list
- Find the second last node of a linked list in single traversal
- Find the Second Largest Element in a Linked List
- Difference between Singly linked list and Doubly linked list
- XOR Linked List – A Memory Efficient Doubly Linked List | Set 2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.