Write a function, depth_first_values, that takes in the root of a binary tree. The function should return a list containing all values of the tree in depth-first order.
Hey. This is our first binary tree problem, so you should be liberal with watching the Approach and Walkthrough. Be productive, not stubborn. -AZ
a = Node('a')b = Node('b')c = Node('c')d = Node('d')e = Node('e')f = Node('f')a.left = ba.right = cb.left = db.right = ec.right = f# a# / \# b c# / \ \# d e fdepth_first_values(a)# -> ['a', 'b', 'd', 'e', 'c', 'f']
a = Node('a')b = Node('b')c = Node('c')d = Node('d')e = Node('e')f = Node('f')g = Node('g')a.left = ba.right = cb.left = db.right = ec.right = fe.left = g# a# / \# b c# / \ \# d e f# /# gdepth_first_values(a)# -> ['a', 'b', 'd', 'e', 'g', 'c', 'f']
a = Node('a')# adepth_first_values(a)# -> ['a']
a = Node('a')b = Node('b')c = Node('c')d = Node('d')e = Node('e')a.right = b;b.left = c;c.right = d;d.right = e;# a# \# b# /# c# \# d# \# edepth_first_values(a)# -> ['a', 'b', 'c', 'd', 'e']
depth_first_values(None)# -> []