Given a linked list, print alternate nodes of this linked list.
Input : 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10 Output : 1 -> 3 -> 5 -> 7 -> 9 Input : 10 -> 9 Output : 10
Recursive Approach :
1. Initialize a static variable(say flag)
2. If flag is odd print the node
3. increase head and flag by 1, and recurse for next nodes.
1 3 5 7 9
- Print the alternate nodes of linked list (Iterative Method)
- Sum of the alternate nodes of linked list
- Product of the alternate nodes of linked list
- Delete alternate nodes of a Linked List
- Alternate Odd and Even Nodes in a Singly Linked List
- Reverse alternate K nodes in a Singly Linked List
- Given a linked list, reverse alternate nodes and append at the end
- Print nodes of linked list at given indexes
- Print the last k nodes of the linked list in reverse order | Recursive approach
- Print the last k nodes of the linked list in reverse order | Iterative Approaches
- Merge a linked list into another linked list at alternate positions
- Alternate sorting of Linked list
- Append odd position nodes in reverse at the end of even positioned nodes in a Linked List
- Rearrange a linked list in to alternate first and last element
- Delete a linked list using recursion
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.