Question: Selection ( A , k ) finds the k th smallest element of an array A . For example, if A = [ 3 ,
Selection finds the th smallest element of an array For example, if
and then Selection returns Here is pseudocode for a divide and conquer algorithm for
Selection.
Note that in the following pseudocode I index A starting at not is the subarray of
from index to inclusive of both and
a What is the worst case runtime of this algorithm if ChoosePivot somehow always chooses the
pivot to be the median of the array, and the array is originally size
b Create and analyze a recurrence relation for the runtime of this algorithm if ChoosePivot somehow
always chooses the pivot to be the smallest element in the array, and the array is originally size
c Now consider the case that ChoosePivot chooses a pivot uniformly at random. Consider the
random variable for
What the probability and being compared are trying find the order
statistic, and
Use linearity expectation, and properties the expectation value indicator random
variables create explicit expression involving sums that gives the average number
comparisons done over the coruse the algorithm.
What the probability and being compared are trying find the order
statistic, and
What the probability and being compared are trying find the order
statistic, and
Use linearity expectation, and properties the expectation value indicator random
variables create explicit expression involving sums that gives the average number
comparisons done over the coruse the algorithm. which the number times the and smallest elements
A are compared some point the algorithm.
What the sample space this problem?
Explain why indicator random variable.
iii. What the probability and being compared are trying find the order
statistic, and
What the probability and being compared are trying find the order
statistic, and
What the probability and being compared are trying find the order
statistic, and
Use linearity expectation, and properties the expectation value indicator random
variables create explicit expression involving sums that gives the average number
comparisons done over the coruse the algorithm.
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
