We have discussed different methods of linked list insertion. How to recursively create a linked list?
Recursively inserting at the end:
To create a Linked list using recursion follow these steps. Below steps insert a new node recursively at the end of linked list.
Recursively traversing the list:
The idea is simple, we print current node and recur for remaining list.
Below is complete program to demonstrate working of insert and traverse a linked list.
6 8 10 12 14
This article is contributed by AMIT KUMAR. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Insertion in Unrolled Linked List
- Doubly Linked List | Set 1 (Introduction and Insertion)
- Circular Singly Linked List | Insertion
- Insertion Sort for Singly Linked List
- Doubly Circular Linked List | Set 1 (Introduction and Insertion)
- Insertion at Specific Position in a Circular Doubly Linked List
- Insertion in a sorted circular linked list when a random pointer is given
- Check if linked list is sorted (Iterative and Recursive)
- Search an element in a Linked List (Iterative and Recursive)
- Recursive function to delete k-th node from linked list
- Modify contents of Linked List - Recursive approach
- Recursive approach for alternating split of Linked List
- Find Length of a Linked List (Iterative and Recursive)
- Recursive Approach to find nth node from the end in the linked list
- Circular Linked List | Set 2 (Traversal)
- Print the last k nodes of the linked list in reverse order | Recursive approach
- Recursive selection sort for singly linked list | Swapping node links
- Find the second last node of a linked list in single traversal
- Python program to find middle of a linked list using one traversal
- Recursive Insertion Sort