Quick Sort
- Pick a pivot element p in the array
- Partition the array into
- Recursively sort the two partitions.
Key benefit: No temporary array!
Pseudocode
Time Complexity
- Best Case:
- Average Case:
- Worst Case:
Space Complexity
- Worst Case:
Implementation details
- How to pick a pivot?
- Random Element
- Median of three
- Dealing with duplicates? Quicksort doesn’t perform well with lots of duplicate elemnts
CS240
See Partition.