CC7_03 Write a function that takes in a Binary Tree and returns a list of its branch sums ordered from leftmost branch sum to rightmost branch sum. A branch sum is the sum of all values in a Binary Tree branch. A Binary Tree branch is a path of nodes in a tree that starts at the root node and ends at any leaf node. Each BinaryTree node has an integer value, a left child node, and a right child node. Children nodes can either be BinaryTree nodes themselves or None. Sample input: Sample output: Given the following implementation to calculate_branch_sums(node, running_sum, sums), which test case would fail? It is guaranteed all the other methods are correct. The Input Binary Tree is built using the following method. We have also drawn the correct binary tree for each test case using comments below. It is guaranteed those binary trees are correct. 单项选择题

A

The implementation is correct and would pass both test cases.

B

The implementation would fail both test cases.

登录即可查看完整答案

我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。

类似问题

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!