Given a singly linked list and the task is to find the middle of the linked list.
Input : 1->2->3->4->5 Output : 3 Input : 1->2->3->4->5->6 Output : 4
We have already discussed Iterative Solution. In this post iterative solution is discussed. Count total number of nodes in the list in recursive manner and do half of this, suppose this value is n. Then rolling back through recursion decrement n by one for each call. Return the node where n is zero.
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.
- 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
- Recursively Reversing a linked list (A simple implementation)
- Find the middle of a given linked list in C and Java
- Find kth node from Middle towards Head of a Linked List
- Python program to find middle of a linked list using one traversal
- Find smallest and largest elements in singly linked list
- Find the common nodes in two singly linked list
- Find minimum and maximum elements in singly Circular Linked List
- Given a linked list of line segments, remove middle points
- Delete middle of linked list
- Insert node into the middle of the linked list
- Make middle node head in a linked list
- Iterative approach for removing middle points in a linked list of line segements
- Insert N elements in a Linked List one after other at middle position
- Traverse Linked List from middle to left-right order using recursion
- Given only a pointer/reference to a node to be deleted in a singly linked list, how do you delete it?
- Given only a pointer to a node to be deleted in a singly linked list, how do you delete it?
- Function to check if a singly linked list is palindrome
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.