Partitions around a pivot so smaller elements move left, then recurses on each side.
Partitions around a pivot so smaller elements move left, then recurses on each side.
Time complexity: O(n log n). Space complexity: O(log n).
Core idea — Pick a pivot and partition the sub-array so smaller values move left and larger move right, then recurse on each side.
What each pass accomplishes — After each partition the pivot lands in its final sorted position — everything to its left is smaller and everything to its right is larger — so every partition permanently places at least one element. The two sides are then sorted the same way.
Use the interactive visualizer above to run Quick Sort on your own input and watch every comparison, swap, and operation animate step by step — pause, scrub, or replay at any speed.