We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Because you are first putting it as head.next which means if it IS null, it will already be at head.next and the return will basically return to the pre-recursion of the last function just to get print a null value
What his code does is, if head.next is null, it will return so that head.data will be printed, otherwise, head=head.next will happen and that will be put into the same function
Print in Reverse
You are viewing a single comment's thread. Return to all comments →
Because you are first putting it as head.next which means if it IS null, it will already be at head.next and the return will basically return to the pre-recursion of the last function just to get print a null value
What his code does is, if head.next is null, it will return so that head.data will be printed, otherwise, head=head.next will happen and that will be put into the same function