Interview Question on link list 

Write a recessive function to reverse a singly linked list in c? some time interviewer at beginning level can ask this type of question to test the basic concept of data structure in c. This is one of famous interview question on data structure.

How to 

The general recursive algorithm for this is:



  1. Divide
    the list in
    2
    parts – first node and rest of the list.
  2. Recursively call reverse for the

    rest
    of the linked list.
  3. Link

    rest
    to
    first
    .
  4. Fix

    head
    pointer

      Below is pictorial action of above steps to reverse a singly linked list by recursion.

Reverse a Linked List using Recursion in C

Ref:

http://stackoverflow.com/questions/14080758/reversing-a-linkedlist-recursively-in-c                                                                           http://cslibrary.stanford.edu/105/LinkedListProblems.pdf