Monday, February 18, 2013

Link List

 Input linked list is given as 1->2->3->4->5.
 Expected Output list is 5->1->4->2->3

Ans:-

1) Reverse the List
2) Display the first node and Reverse the remaining list
3) Repeat same process until NULL.


void fn(struct node * node)
{
    struct node * current = node;
    reverse(&current);
    if(current->next != NULL)
        rec_recursive(current->next);
}