Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 =2k-1 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: bst_balanced(A, a, b, tree)
bst_balanced(A, lo, hi, tree)
if (lo <= hi)
m =(lo + hi)//2
tree.insert(A[m])
bst_balanced(A, lo, m-1, tree)
bst_balanced(A, m+1, hi, tree)
(a) Suppose the array A ={1,3,5,6,8,11,13,15,20,22,23,25,28,30,33], and n=15. Show the BST after the first 6 insertions
(b) Write the recurrence T(n) for the general case.
(c) If n=1023 and lo =1 and ho =1023, the 1st to be inserted is at index 512. Determine the index of the 513th 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 1? Explain your answer.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is the message repetition?

Answered: 1 week ago

Question

What is the budget for this project?

Answered: 1 week ago