标签:uva acm data structure binary trees
题目如下:
Tree |
You are to determine the value of the leaf node in a given binary treethat is the terminal node of a path of least value from the root of thebinary tree to any leaf. The value of a path is the sum of values of nodesalong that path.
3 2 1 4 5 7 6 3 1 2 5 6 7 4 7 8 11 3 5 16 12 18 8 3 11 7 16 18 12 5 255 255
1 3 255
现根据中序和后序建树,再先序遍历树,对每个叶子节点,既要保存当前的和,又要保存当前的叶子节点。
AC的代码如下:
标签:uva acm data structure binary trees
原文地址:http://blog.csdn.net/u013840081/article/details/27185251