Question: If one has a set, S, of n items, where n is even, then the median item in S is the average of the ith

If one has a set, S, of n items, where n is even, then the median item in S is the average of the ith and (i + 1)st smallest elements in S, where i = n/2. Describe an efficient algorithm for computing the median of such a set S that is stored in a binary search tree, T, where each node, v, in T is augmented with a count, nv, which stores the number of items stored in the subtree of T rooted at v.

Step by Step Solution

3.53 Rating (173 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Approach 1 Using On extra memory 1 Create an empty arrayvector 2 Do an inorder traversal of the B... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Data Structures Algorithms Questions!