Question: Let T be a complete binary tree with n = 2k-1 nodes. The nodes are numbered in level order with the root labeled 1, its

Let T be a complete binary tree with n = 2k-1 nodes. The nodes are numbered in level order with the root labeled 1, its two children labelled 2 and 3, etc. Let Ti be the subtree whose root is node i, and so T1 = T. Every node i has a value VALU] which can be positive or negative or zero. We define WT( to be the weight of subtree i, given by the sum of all values of the nodes in Ti. The problem is to find the maximum weight of all subtrees of T a, Give a recurrence for WT b. Give a divide-and-conquer algorithm that finds the maximum WT() given the array VAL c. What are the space and time complexities of your D&C algorithm? d. Give a dynamic programming algorithm that finds the maximum WT(i) given the array VAL. e. What are the space and time complexities of your dynamic programming algorithm? ()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
