• + 6 comments

    It's recursion, calling the function itself again, but with the slightly smaller problem of a linked list with one less element at the front. Let's step through the code.

    The function gets called with the whole linked list. 
        If the list is empty,
        	insert the element as the head.
        Otherwise if there is no element after the head,
        	put the data after the head.
        Otherwise,
        	call the function with all of the elements except for the current head