Trees & BSTs

Concept Lab
Practice Problems
Python Execution SynchronizerActive Line: 1
1
def invert_tree(root):
2
    if root is None:
3
        return None
4
        
5
    root.left, root.right = root.right, root.left
6
    
7
    invert_tree(root.left)
8
    invert_tree(root.right)
9
    
10
    return root
No execution event recorded.
Custom Input:
Loading trace state...
Step 0 / 0