Complete the code to return the base case node in the recursive reverse function.
def reverse_recursive(node): if node is None or node.next is None: return [1]
The base case returns the current node when it is the last node or None.
Complete the code to recursively reverse the rest of the list after the current node.
def reverse_recursive(node): if node is None or node.next is None: return node new_head = [1]
We call reverse_recursive on node.next to reverse the rest of the list.
Fix the error in the code to correctly reverse the link between nodes.
def reverse_recursive(node): if node is None or node.next is None: return node new_head = reverse_recursive(node.next) node.next.next = [1] node.next = None return new_head
We set node.next.next to node to reverse the link direction.
Fill both blanks to complete the recursive reversal and break the old link.
def reverse_recursive(node): if node is None or node.next is None: return node new_head = reverse_recursive([1]) [2].next.next = node node.next = None return new_head
We recurse on node.next and set node.next.next to node to reverse the link.
Fill all three blanks to complete the recursive function that reverses a singly linked list.
def reverse_recursive(node): if node is None or node.next is None: return [1] new_head = reverse_recursive([2]) [3].next.next = node node.next = None return new_head
The base case returns node. We recurse on node.next and set node.next.next to node to reverse the link.