Question: 2 . Given an integer array A [ 1 . . n ] , k - Heavy Hitter is any element whose frequency is more

2. Given an integer array A[1..n], k-Heavy Hitter is any element whose frequency is more than
n/k. That is, x such that |{i|A[i]= x}|> n/k.
(a) At most how many k-Heavy-Hitters are possible?
(b) Show an algorithm which can find all k-heavy hitters in O(n log k). You may assume n
and k both to be powers of 2.(Hint: Find the median first and then recurse on both
sides. Stop when problem size become <= n/k).

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!