Question: I was searching on how can I print a reverse of linked list and I found this piece of code 

```
/* Function to reverse the linked list */
void printReverse(struct node* head)
{
    // Base case  
    if (head == NULL)
       return;

    // print the list after head node
    printReverse(head->next);

    // After everything else is printed, print head
    printf("%d  ", head->data);
}

```

The problem is that I do not understand the part where it reaches the last pointer which points to NULL and how it comes back one by one and prints the linked list in reverse order.

Is the return statement what makes it go step by step back? Or something else? Please help because I do not understand.

Answer: 
This is a recursive function. Recursive functions work by pushing variables onto the execution stack. The execution order pops off the stack in reverse order from the order it was pushed on the stack. This means that the last execution prints first, then the one previous to that, and so forth until all executions of printReverse print their values.
This is a recursive function; that is to say, it calls itself.

Let's use the sequence `example` as your example data:

When you first run the function, it's pointing at the head, and the head is the item containing the data `e`. It has a `next` property, which is the item containing the data `x`. Therefore, `head == NULL` evaluates `False` and the `if` statement doesn't fire.

The function then calls a second copy of itself, pointing to the next item in the list - the item containing `x`. This has a `next` property, which is the item containing `a`. The function then calls a third copy of itself with this item, and so on and so forth until it hits the final `e`, and calls a copy of itself with the `next` property of that item - that is to say, it calls itself with `NULL` as the input.

This copy of the function then `return`s due to the `if` statement- crucially, it `return`s to the function that called it, in this case the copy of itself the level above. This copy then carries on where it left off, executing `printf("%d ", head->data);` - in this case, it prints an `e`. Then it falls out of the body of the function and so `return`s to the function that called it. This copy of the function will have a `head->data` value of `l`, and this will print as above. As such, it then runs through back up the chain until it gets to the original function call, prints the first `e`, and then returns to the function that called it.

Hope this makes sense, I know it's not the best or most elegant explanation of recursion but there's a lot of material out there if this is confusing explaining exactly how recursion works and how useful it can be!