Skip to content

Quick sort
one step at a time.

Partition around a pivot so smaller numbers sit left and bigger ones right, putting the pivot in its final place, then sort each side.

Free to use. Step forward and back at your pace, and share a link to the exact step you are stuck on.

What you actually watch.

The part a dry run on paper loses: the state, at every step.

Partition around a pivot so smaller numbers sit left and bigger ones right, putting the pivot in its final place, then sort each side. That sentence is easy to agree with and hard to hold in your head on step nine, which is where most people lose the thread.

So the visualiser keeps it in front of you: every comparison and every swap, pass by pass. The line of code being executed is highlighted as the picture changes, so the drawing and the code never drift apart. Step forward, step back, or let it play.

Put your own input in. Quick sort on a clean example teaches you the shape; quick sort on an empty input, a single element, or one with duplicates teaches you the thing an interviewer asks about.

How it runs, step by step.

The same order the visualiser moves in, so the list and the picture match.

  1. 1Compare two elements and decide which belongs first.
  2. 2Move elements so the part you have handled is in order.
  3. 3Repeat over the rest, shrinking what is still unsorted.
  4. 4Finish when no move is left to make.

Where people get this one wrong.

These are not made up. Each one is a switch in the tool: turn it on, run the same input, and watch the state go wrong.

  • Middle pivotSwaps the middle number to the end and uses it as the pivot. On Already sorted it splits evenly, so the n(n−1)/2 worst case disappears.
  • Bug: pivot into a[i]Swaps the pivot into a[i], the last slot of the ≤ region, instead of a[i + 1]. A smaller number lands right of the pivot: most inputs then recurse forever, and Already sorted comes out in the wrong order.

What it costs.

The two numbers an interviewer will ask for, and what they mean here.

Time
O(n log n) avg, O(n²) worstcounted as real operations while it runs, not quoted from a table
Space
O(log n)what the algorithm holds besides the input itself
Pattern
SortingHow order is built, one comparison at a time.

Everything in the app, in one place.

Practice, interviews and the tools, all free to start. Swipe to see the rest.

Free to start: 100 AI credits when you sign up and 100 every month. Start free in the app

About quick sort.

Open it in the app and the answers are easier to see than to read.

Open the visualiser
What does the quick sort visualiser show?

Every step of the algorithm on input you choose: every comparison and every swap, pass by pass, with the line of code being executed highlighted beside it. You can step forward, step back, or let it play. Spelled visualizer or visualiser, it is the same tool.

What is the time complexity of quick sort?

O(n log n) avg, O(n²) worst time and O(log n) space. The visualiser counts the real operations as it runs, so you can watch the number grow instead of taking the formula on trust.

Why does my quick sort code fail on some inputs?

Usually one of the known traps. The visualiser ships the real ones for this algorithm (pivot into a[i]), so you can switch the bug on, run it, and watch exactly where the state goes wrong.

Can I use my own input?

Yes. Type your own array, string or graph and the algorithm runs on that, including the edge cases that break a solution in an interview.

Is it free?

Yes. The app is free to start, with 100 AI credits when you sign up and 100 every month, and watching an algorithm costs no credits.