Quick Sort Visualization
Efficient divide-and-conquer algorithm that selects a 'pivot' element and partitions the array around it.
Step: 0 / -1
Speed
Pseudocode
1function quickSort(arr, low, high)
2 if low < high
3 pi = partition(arr, low, high)
4 quickSort(arr, low, pi - 1)
5 quickSort(arr, pi + 1, high)
6
7function partition(arr, low, high)
8 pivot = arr[high]
9 i = low - 1
10 for j = low to high - 1
11 if arr[j] < pivot
12 i++
13 swap(arr[i], arr[j])
14 swap(arr[i + 1], arr[high])
15 return i + 1
Time Complexity
Best CaseO(n log n)
Average CaseO(n log n)
Worst CaseO(n²)