Quick Sort Visualization
How Quick Sort Works
Quick Sort is a divide-and-conquer algorithm. It works by selecting a 'pivot' element from the array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot. The sub-arrays are then sorted recursively. This process continues until the entire array is sorted.
function quickSort(array, low, high):
if low < high:
pivotIndex = partition(array, low, high)
quickSort(array, low, pivotIndex - 1)
quickSort(array, pivotIndex + 1, high)
visualize(array, low, high, pivotIndex)
function partition(array, low, high):
pivot = array[high]
i = low - 1
for j from low to high - 1:
if array[j] < pivot:
i++
swap array[i] and array[j]
swap array[i + 1] and array[high]
return i + 1