Question: use python help me with this problem Question 2: Largest Subtree Total > For a treet = (t1, t2), the subtrees of t consist of

use python help me with this problemuse python help me with this problem Question 2: Largest Subtree Total> For a treet = (t1, t2), the subtrees of t consist

Question 2: Largest Subtree Total > For a treet = (t1, t2), the subtrees of t consist of t, and of the subtrees of t and t2. That is, in formulas, subtrees(t) = {t} U subtrees(t) U subtrees(t2). To give a concrete example, the subtrees of t = (3,(4,5)) are: (3,(4,5)) 3 (4,5) .4 5 . Given a tree t, write a function max_subtree_total(t) that computes the largest total of any subtree in t. Of course, if the numbers in the tree are all non-negative, then the largest total corresponds to the complete tree, but this is not the case if there are leaves with value smaller than 0. For instance, for the tree (-2, (3, 4)) the largest total corresponds to the subtree (3, 4), which has total 7. If you wish, you can use the total function you developed in the previous question, but you don't have to. [104] def max_subtree_total (t): ### YOUR CODE HERE ### 5 points. Some simple cases first. check_equal (max_subtree_total(3), 3) check_equal (max_subtree_total((4, 5)), 9) Success Success ### 10 points. More complex cases. check_equal (max_subtree_total((-3, 4)), 4) check_equal (max_subtree_total((-3, -4)), -3) check_equal (max_subtree_total(((-3, 5), (2, 1))), 5) check_equal (max_subtree_total((((4, 5), -3), (12, (3, 4)))), 25)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!