grokking-algorithms/chapter4/README.md

10 lines
410 B
Markdown
Raw Normal View History

2024-02-06 22:04:37 +00:00
# Quicksort
2024-02-06 21:53:17 +00:00
2024-02-06 22:04:37 +00:00
Similar to the previous recursive function, quicksort uses divide and conquer.
2024-02-06 21:53:17 +00:00
2024-02-06 22:04:37 +00:00
The base case occurs for an array size 0 or 1 (doesn't need to be sorted).
2024-02-06 21:53:17 +00:00
2024-02-06 22:04:37 +00:00
The recursive case works by partitioning the array around a chosen pivot repeatedly until the base case is met and then combining all sorted sub-arrays.
2024-02-06 21:53:17 +00:00
Note. Quicksort should be implemented using a random pivot to ensure average runtimes.