Codacoda
Back to Academy

sorting

Quick Sort

Quick Sort is a divide-and-conquer algorithm that picks a 'pivot' element and partitions the array around it, placing smaller elements before and larger elements after the pivot. It then recursively sorts the sub-arrays.

Use Cases

  • General-purpose sorting with good average performance
  • In-place sorting when memory is constrained
  • Large datasets where average-case O(n log n) is acceptable

Complexity Analysis

MetricBestAverageWorst
TimeO(n log n)O(n log n)O(n²)
SpaceO(log n)

Visualization

64
34
25
12
22
11
90
Speed:1x
Initial arrayStep 1 / 32

Implementation

Output

Click "Run Code" to see output...