Sorting & Selection Checkpoint

Trace fresh cases, diagnose a failed invariant, then revisit the linked explanation and implementation.


Get every question correct to pass this checkpoint. You can review feedback, revise your answers, and submit again.

1. How many inversions are in [3,1,2]? Answer with the integer only.
2. Quickselect partitions into values <p, =p, and >p. The requested rank lies in the equal segment. What next?

Select one answer.

3. During inversion counting, left remainder is [4,7] and the next right value is 3. How many inversions does taking 3 add?

Select one answer.

4. What is the second-smallest value in [8,3,3,10], counting duplicates? Answer with the integer only.
5. A deterministic quickselect always chooses the first element as pivot on sorted distinct data. What worst case can result?

Select one answer.

6. A three-way partition swaps a too-large scan value with the unknown rightmost value. Why must the scan index stay put?

Select one answer.

Join Discord