I’m learning quicksort from Sedgwick’s book. One of his exercise problems is
Write a program that sorts an array that is known to contain just two distinct key values.
View Solution
I think I understand the solution. It runs in O(n). I don’t however understand the relation between this and quicksort? I fail to see any sort of partitioning like in quick sort. All that is done here is deposit lesser and greater elements beyond respective boundaries pointed to by lt and gt.
Solution is just like quicksort whit single pass.
Quick sort pseudo code:
Where soultion you looking for is same as quicsort exept 1,5,6