Print reverse of a linked list without actually reversing

That is a linked list traversal problem, Displaying the linked list node in reverse order without effect (modified) in original linked list. Lets see few example.

Example A
Input List : 1 → 2 → 8 → 4 → 9 → 6 → NULL
Output     : 6   9   4   8   2   1
Example B
Input List : 1 → 2 → 3 → NULL
Output     : 3   2   1

This problem are targeted to understand iterative and recursive mechanism in programming language. Because recursion is simplest solution of this problem. And iterative is based on stack data structure. This post are based on recursive solution.




Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2022, kalkicode.com, All rights reserved