10
0 Likes

DSA Crash Course [Part 41] - Breadth First Values Approach

In this lesson, Alvin explores the strategy to solving the following interview problem:

Write a function, breadth_first_values, that takes in the root of a binary tree. The function should return a list containing all values of the tree in breadth-first order.

a = Node('a')
b = Node('b')
c = Node('c')
d = Node('d')
e = Node('e')
f = Node('f')
a.left = b
a.right = c
b.left = d
b.right = e