Reverse a Linked List using Recursion

Write a program to reverse a linked list using recursion. Given a linked list print them in reverse order using recursion. This question is mostly asked in interviews.

In my last post, I have explained how to reverse a linked list using an iterative approach. In this post, We will learn how to reverse a linked list using recursion.  The time complexity for both iterative and recursive approach is O(n).

What is a Linked List

Linked list is a linear collection of data elements, called nodes. Each node is connected to a next node by links ( using a pointer). So linked list is a group of nodes which together represent a sequence. Each node consists of two parts a data and a pointer to next node.

Subscribe Our Tutorials

Get Latest Updates on Facebook

I assume you have basic understand of recursion. If you are not familiar with recursion then check my previous post on recursion concept and difference between recursion and iteration.

Program to Reverse a Linked List using Recursion

Some more questions on linked list –

Insert a node at the head of a linked list

Count number of nodes in a linked list


About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.
Tagged , , . Bookmark the permalink.

One Response to Reverse a Linked List using Recursion

  1. Aman Rustagi says:

    Algorithm to reverse a linked list using iteration
    1. We will use three node pointer “previous”, “current” and “next” to keep track of previous, current and next node during linked list reversal.
    2. Initialize current pointer to head and previous pointer to NULL.
    3. Traverse linked list from head till current->next != NULL.
    4. In every iteration, set current->next = previous; and move all three pointers to next node.
    5. Return previous pointer. This is the new head pointer of reversed linked list.

Leave a Reply

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