Question: 2 . Given an integer array A [ 1 . . n ] , k - Heavy Hitter is any element whose frequency is more
Given an integer array An kHeavy Hitter is any element whose frequency is more than
nk That is x such that iAi x nk
a At most how many kHeavyHitters are possible?
b Show an algorithm which can find all kheavy hitters in On log k You may assume n
and k both to be powers of Hint: Find the median first and then recurse on both
sides. Stop when problem size become nk
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
