Linked List Recursion
Recursion Recursion recipe Base case: “Oh I know the answer” General case: “I know who to ask for the answer” OR “I know part of the answer and who to ask about the rest”
LL Base Cases Linked Lists base case options: Have a link to last node current->next == nullptr Have an element to work with Have a nullptr Gracefully handles empty list
LL General Case Have a pointer, and 1+ nodes off next Work with current Recursive call to current->next
Functions Recursive print: https://goo.gl/hMmVVX
Functions Recursive get length: https://goo.gl/hMmVVX nullptr base case gives right answer for empty list https://goo.gl/hMmVVX
Functions Recursive getLast https://goo.gl/hMmVVX Makes no sense on empty list https://goo.gl/hMmVVX