Question: We have a sorted array A of n = 2 k - 1 unique numbers. Assume A is indexed a . . b . The
We have a sorted array A of n k unique numbers. Assume A is indexed a b The following recursive algorithm will insert them into an empty BST and produce a full BST Assume tree is an empty BST
Call: bstbalancedA a b tree
bstbalancedA lo hi tree
if lo hi
m lo hi
tree.insertAm
bstbalancedA lo m tree
bstbalancedA m hi tree
a Suppose the array A and n Show the BST after the first insertions
b Write the recurrence Tn for the general case.
c If n and lo and ho the st to be inserted is at index Determine the index of the th node to be inserted. Explain your answer.
d What is the maximum number of nodes we could add into the tree in c and only increase the tree height by Explain your answer.
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
