Question: Problem 3 ( 2 4 marks ) Consider the following binary tree made up of both positive and negative integers. Our problem is to find
Problem marks
Consider the following binary tree made up of both positive and negative integers.
Our problem is to find the maximum possible sum from one leaf to another in a binary tree. In the example above, the maximum sum is which starts at leaf node and ends at leaf node that is
a marks Outline an algorithm that finds the maximum sum between two leaf nodes using a single traversal of the binary tree.
b Implement marks and test marks your algorithm in part a You may wish to store additional information in each node.
c marks Augment your code in part b to return the actual values along the maximumsum path between the two leaf nodes.
Page of
Problem marks
Using the AVL implementation on Blackboard as a base, reimplement marks and test marks the Remove method to avoid retraversing the tree as discussed in class
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
