Loading...
Loading...
Loading...
Print all keys of a binary search tree from smallest to largest, separated by spaces.
Example 1
Input
8 3 10 1 6 # 14 # # 4 7 13
Output
1 3 4 6 7 8 10 13 14
Example 2
Input
2 1 3
Output
1 2 3
Try the problem first. Open one hint at a time.
Visit the left subtree, then the node, then the right subtree.
A generator with yield from keeps it short.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor