Binary Tree Traversal Sum Of Each Depth
问题 I am looking for an algorithm or modification of an efficient way to get the sum of run through of a tree depth, for example: Z / \ / \ / \ / \ X Y / \ / \ / \ / \ A B C D The number of final leaves is four so us have four final sums and they would be this respectively. [Z+X+A] [Z+X+B] [Z+Y+C] [Z+Y+D] If someone could guide me in the right direction into getting the sums of all possible depths, that would be great. This will be done in python with fairly large trees. 回答1: You can recurse over