Reversing a linked list recursively and iteratively