Question: ( a ) ( 1 6 points ) Given a binary search tree of height h , show how to implement range ( x ,
a points Given a binary search tree of height h show how to implement rangex y in Ohk
time, where k is the number of elements that are at least x and at most y
Can we do this operation even faster? It turns out that we can! In particular, for a binary search
tree of height h we can do this in Oh time. We will prove this in the rest of the problem.
b points Describe an extra piece of information that you will store at each node of the tree,
and describe how to use this extra information to do the above range query in Oh time.
Hint: Think of keeping track of a size.
c points Describe how to maintain this information in Oh time when a new node is inserted
note that there are no rotations on an insert its just the regular binary search tree insert, but
you need to update information appropriately
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
