Skip to content
Code ReadingIn-order Walk
Predict the Output

In-order Walk

The tree is written as (value, left, right) tuples. Left, then the node, then right: what is printed?
1tree = (8, (3, (1, None, None), (6, None, None)), (10, None, (14, None, None)))
2
3def walk(t):
4 if t is None:
5 return []
6 value, left, right = t
7 return walk(left) + [value] + walk(right)
8
9print(walk(tree))