Question: 7 . For n distinct elements with positive weights x 1 , x 2 , . . . , xn with positive weights w 1

7. For n distinct elements with positive weights x1, x2,..., xn with positive weights w1, w2,..., wn such that
i=1nwi=1 the weighted lower median is the element xk such that
xixk wi 12
Observe that the median of x1, x2,..., xn is the weighted median for wi =1n for i =1,2,..., n.
(a) Show how to compute the weighted median of n elements in O(n log n) worst case time using sorting. You do not need to write pseudo-code, simply explain your approach and justify the claim for its complexity.
(b) Show how to compute the weighted median in O(n) time using the Select algorithm discussed in class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Programming Questions!