Question 16
Is standard in-place Quick Sort a stable sorting algorithm?
Standard in-place Quick Sort is NOT stable because partitioning swaps elements across the pivot without preserving relative order of equal elements.
Is standard in-place Quick Sort a stable sorting algorithm?
Standard in-place Quick Sort is NOT stable because partitioning swaps elements across the pivot without preserving relative order of equal elements.
Is standard Merge Sort a stable sorting algorithm?
Standard Merge Sort is STABLE when the merge step takes from the left subarray first whenever left element <= right element.
What is the call stack space complexity of standard Quick Sort in the worst case?
In the worst case (unbalanced splits of 1 and n-1), the recursion depth reaches n, requiring O(n) call stack space.
How can the recursion stack space of Quick Sort be bounded to O(log n) even in the worst case?
By always making the recursive call on the smaller partition (size <= n/2) and eliminating tail recursion on the larger partition, stack depth is strictly bounded by O(log n).
To avoid integer overflow when computing the middle index in Binary Search on large arrays, which formula should be used?
(low + high) can overflow standard 32-bit signed integers if low + high >= $2^31$. low + (high - low) / 2 mathematically prevents integer overflow.