In class, we learned about quicksort algorithm with a single pivot. for this problem we will modify quicksort to use two instead of a single pivot. we will partition the array using both pivots. the elements smaller than both are left of the smaller pivot, the elements larger than both are to the right of the larger pivot and elements in-between are in the middle
(a) write pseudocode for the modified partition routine.
(b) write pseudocode for quicksort algorithm (use the modified partition routine)
(c) find the average number of comparisons that your partition function carries out, exactly. (hint: you would have to find the probability of all possible pivot values and sum up the number of comparisons with the probability of it happening.)
(d) let us assume the two pivots split the array into three equal sized partitions. write the recurrence equation and solve it

Solved
Show answers

Ask an AI advisor a question