I have a two black boxes that, if I feed them my array, give me pivots in consta
ID: 3590389 • Letter: I
Question
I have a two black boxes that, if I feed them my array, give me pivots in constant time with the following properties: the first black box returns me a pivot whose value falls within the 20-40th percentile of the input array. The second black box returns me a pivot that falls within the 60-80th percentile. I don’t know how the pivots are selected, they may not be random (ie, you can’t count on them being evenly distributed in their designated ranges.) If you had just the first black box, how would you use it for the selection algorithm? Give the recurrence and analyze the running time. How would you design a selection algorithm that partitions by using two pivots simultaneously? Write a recurrence for the running time and solve.
Explanation / Answer
Use divide and conquer algorithm to design and solve these kind of problems.
write down and solve the number of recurrences
and start applying the algorithm.
select the first box and use the algorithm and note down the recurrences
repeat with the second box.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.