How to print python binary tree from top to bottom
This article is about how to print python binary tree from top to bottom, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Order
Mainly record the binary tree printed from top to bottom
The topic prints the binary tree from top to bottom, and the nodes on the same layer print in the order from left to right, and each layer prints to a line. For example, given a binary tree: [3recover9re20recollary nullrecover157], 3 /\ 920 /\ 157returns its hierarchical traversal result: [[3], [9recover20], [15recover7]] hint: the total number of nodes