use bfs

use bfs
dfs is also ok. it needs height. print the node according to the height