Quicksort and partitioning

Which three groups does a three-way partition produce?

Examples

Worked example

Input
[5, 2, 5, 9, 1], pivot 5
Expected output
[2, 1], [5, 5], [9]

Hints and solution

Hint 1

Write down the starting state and walk through one example by hand.

Reveal worked answer

Compare each item with 5 and place it into the lower, equal, or greater group.

Back to the lesson