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.
- Delete Nth node from the end of the given linked list
- Recursive Approach to find nth node from the end in the linked list
- Delete a node in a Doubly Linked List
- Delete every Kth node from circular linked list
- Delete a Linked List node at a given position
- Delete a given node in Linked List under given constraints
- Delete a Doubly Linked List node at a given position
- Delete a Node from linked list without head pointer
- Given only a pointer 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
- Given only a pointer/reference to a node to be deleted in a singly linked list, how do you delete it?
- Write a function to delete a Linked List
- Write a function to get Nth node in a Linked List
- Create new linked list from two given linked list with greater element at each node
- Swap Kth node from beginning with Kth node from end in a Linked List