遍历树算法2 - Solve tree problems recursively

2018-04-20
阅读 4 分钟
1.9k
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 最大深度是指从根节点到最远的叶节点经过的节点个数。

遍历树算法 - Traverse A Tree

2018-04-18
阅读 5 分钟
6k
序列化二叉树:把一棵二叉树按照某种遍历方式的结果以某种格式保存为字符串。需要注意的是,序列化二叉树的过程中,如果遇到空节点,需要以某种符号(这里用#)表示。反序列化二叉树:根据某种遍历顺序得到的序列化字符串,重构二叉树。具体思路是按前序遍历“根左右”的顺序,根节点位于其左右子节点的前面,即非空(#)...