Quicksort · Compiler
Quicksort
Count the pivot choices made by three-way quicksort. For each group of two or more elements, choose its first value as pivot and partition into values smaller than, equal to, and greater than it. Preserve input order within each group. Repeat only on the smaller and greater groups. A group of size zero or one uses no pivot.
- Input
- Line 1 contains the length n (1 to 100). Line 2 contains n space-separated integers, each from -1000 to 1000.
- Output
- Print the total number of times a pivot is chosen.
Compiler Explorer runs your code when you run or check it.
Loading your exercise draft…