Saturday, October 22, 2011 No. 11 - Print Binary Trees from Top to Bottom Problem: Please print a binary tree from its top level to bottom level, and print nodes from left to right if they are in same level. For example, it prints the binary tree in Figure 1 in order of 8, 6, 10, 5, 7, 9, 11. A binary tree node is defined as below: struct BinaryTreeNode }; Figure 1: A binary tree sample. If it is printed from top to bottom, it prints 8, 6, 10, 5, 7, 9, 11 sequentially. Analysis: It examines candidates’ understanding of tree traverse algorithms,
Read full article from Coding Interview Questions: No. 11 - Print Binary Trees from Top to Bottom
No comments:
Post a Comment