Given a singly linked list delete node at k-th position without using loop.
Input : list = 9->8->3->5->2->1 k = 4 Output : 9->8->3->2->1 Input : list = 0->0->1->6->2->3 k = 3 Output : 0->0->6->2->3
We recursively reduce value of k. When k reaches 1, we delete current node and return next of current node as new node. When function returns, we link the returned node as next of previous node.
Modified Linked List: 12 15 11 5 6 2 3
This article is contributed by Mohd Saleem. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
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.
- Swap Kth node from beginning with Kth node from end in a Linked List
- Swap Kth node from beginning with Kth node from end in a Doubly Linked List
- Delete every Kth node from circular linked list
- Recursive selection sort for singly linked list | Swapping node links
- Recursive Approach to find nth node from the end in the linked list
- Find kth node from Middle towards Head of a Linked List
- 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?
- Delete a node in a Doubly Linked List
- Delete a given node in Linked List under given constraints
- Delete a Linked List node at a given position
- Delete a Doubly Linked List node at a given position
- Delete a Node from linked list without head pointer
- Delete Nth node from the end of the given linked list
- Create new linked list from two given linked list with greater element at each node
- Floor value Kth root of a number using Recursive Binary Search
- Write a function to delete a Linked List
- Find Length of a Linked List (Iterative and Recursive)
- Search an element in a Linked List (Iterative and Recursive)
- Recursive insertion and traversal linked list