Question: Suppose that we implement the following wrapper algorithm: RepeatedRandomizedApproximateMiddle(A,p) // p is a probability value { K = ...... // K is calculated based on
Suppose that we implement the following wrapper algorithm:
RepeatedRandomizedApproximateMiddle(A,p) // p is a probability value { K = ...... // K is calculated based on p // Below, RandomizedApproximateMiddle is called K times in total min = RandomizedApproximateMiddle(A); // It is called here for the first time
for (i = 1; i < K; i++) { newOne = RandomizedApproximateMiddle(A); // It is called K-1 times here if (newOne < min)
newOne = min;
}
return min; }
RepeatedRandomizedApproximateMiddle calls RandomizedApproximateMiddle exactly K times. It does this to make sure that the probability that RepeatedRandomizedApproximateMiddle returns an element with rank less than n/10 is at least p, where p is an input to the algorithm.
The value K is computed in the beginning of RepeatedRandomizedApproximateMiddle. The place the computation is performed for K is left as blank (......) above in the code. Please fill in the blanks above such that the probability that RepeatedRandomizedApproximateMiddle returns an element with rank less than n/10 is at least p.
YOU MUST SHOW ALL THE STEPS OF YOUR CALCULATION TO GET FULL GRADE. JUST WRITING THE RESULT WILL NOT GET YOU ANY POINT.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
