Question: In class, we have seen the following randomized selection algorithm: Algorithm RSelect ( S , k ) : Input: Sequence S of numbers, integer k
In class, we have seen the following randomized selection algorithm:
Algorithm RSelectS k:
Input: Sequence S of numbers, integer k with S k
Output: kth smallest number in S
if S
then return the only element in S
else p uniformly random element in S;
by scanning S and making S comparisons, divide it into
Sx in S : x p
Sx in S : x p
Sx in S : x p;
if k S
then RSelectS k
else if k SS
then RSelectS k SS
else return p
endif
endif
endif
Let T be the random variable whose value is the number of comparisons made by this
algorithm. With n denoting the length of the sequence S we have shown that the expected
value of T is On
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
