Question: Question 1 : Selection Revisited . . . The Order Selection algorithm we saw in class can be a powerful subroutine. Recall that Select (

Question 1: Selection Revisited ...
The Order Selection algorithm we saw in class can be a powerful subroutine. Recall that
Select (A,k) allows one to find the k th smallest element of an unsorted array A(with n
elements) in time O(n).
Given an (unsorted) array A with n elements, a frequent element is defined as some x that
appears at least |~n4~| times in the array. Describe an algorithm that runs in O(n) time and
finds all the frequent elements (if they exist). For convenience, you may assume that n is
a multiple of 4. Along with pseudocode, provide reasoning showing that your algorithm
returns the correct answer and has O(n) running time.
[Hint: Suppose you find the k th smallest element of A for k=n4,n2,3n4,n. Argue that all
"potential" frequent elements must be one of the elements you found.]
Question 1 : Selection Revisited . . . The Order

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!