Question: This problem is concerned with range queries on a balanced binary search tree T whose keys are distinct ( no two keys in T are
This problem is concerned with range queries on a balanced binary search tree T whose keys are distinct no two keys in T are equalThe range query is a generalization of the ordinary search operation. The range of a range
query on T is defined by a pair xl xr where xl and xr are two numbers and xl xr Note that
xl and xr may not be the keys in T
You know that T can support the ordinary search, insert, and delete operations, each
in Olog n time, where n is the number of nodes of T You are asked to design an algorithm to
efficiently perform the range queries, that is in each range query, you are given a range xl xr
and your algorithm should report all keys x stored in T such that xl x xr Your algorithm
should run in Ok log n time, where k is the number of keys of T in the range xl xr In
addition, it is required that all keys in xl xr be reported in a sorted order.
Note that you are not supposed to augment the tree for this problem. Please make sure you give
the pseudocode for your algorithm.
Such an algorithm of Ok log n time is an outputsensitive algorithm because the
runtime ie Ok log n is a function of the output size k As an application of the range
queries, suppose that the keys of T are student scores in an exam. A range query like
would report all scores in the range in sorted order.
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
