Given a binary tree, return the left view of the tree. Can you implement this both recursively and iteratively?
Use the function signature def left_view(root):. The input is a binary tree whose nodes expose val, left, and right; return a list containing the first visible node from each level, ordered from the root downward. An empty tree returns an empty list. The examples and test cases represent trees in level-order arrays, with null for missing children.
def left_view(root):