Home » Data Structure & Algorithms » Reverse a LinkedList using recursion

Reverse a LinkedList using recursion

 

Question :
WAP to reverse a Linked List using recursion in O(n) time complexity.

Solution :
The problem is solved in recursive way.

Algorithm :
Step 1 : If head is null, then return.
Step 2 : Recursively traverse each node till we reach end .Keep on printing on reaching end.

Program :

OutPut :

 
 


Leave a comment

Your email address will not be published. Required fields are marked *

17 + three =