Question: Quick sort is generally faster than cither merge sort or heap sort, and usually it requires only O ( n ( n ) ) memory;
Quick sort is generally faster than cither merge sort or heap sort, and usually it requires
only Onn memory; however, on occasion, it may require oInn memory and have a o n Inn
run time. Suppose you implement the following algorithm:
If the array size is n use insertion sort;
otherwise, if the call stack already has calls to quick sot on it call heap sort;
otherwise, call quick sort recursively following partition.
Questions:
a Why does this algorithm run in On Inn time even in the worstcase scenario for quick sort?
b Suppose quicksort divides the list into a ratio of : at each step. How large would n have to be
for heap sort to be called even once?
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
