Run one algorithm

Pick an algorithm, scrub the speed, and watch the array get sorted bar-by-bar. Comparisons turn orange, swaps red, finalised bars green. The pseudocode appears below.

Algo
Size
Speed
Pattern
Bubble sort
Compares 0 Swaps 0 Time 0ms
idlecomparedswappedpivot / boundaryfinalised

Pseudocode


      

Race mode

All chosen algorithms sort the same array side-by-side. The first to finish wins. Stats below each bar grid count comparisons and swaps in real time.

Size
Speed
Pattern
Choose competitors:

Time & space complexity

Big-O describes how runtime grows as the input gets bigger. n is the number of items. The right algorithm depends on input size, memory budget, and whether the data is mostly-sorted.

O(n) — fastO(n log n)O(n²) — slow on big data

Stable vs unstable

A stable sort preserves the original order of equal elements. This matters when sorting by multiple keys (e.g. sort by date, then by name — only works if the second sort is stable). Stable: Bubble, Insertion, Merge, Radix. Unstable: Selection, Quick (typical), Heap, Shell.

In-place vs out-of-place

In-place sorts reorder the array using only O(1) or O(log n) extra memory. Merge sort uses O(n) auxiliary memory (it's not in-place in the strict sense). Radix sort uses O(n + k) where k is the digit base.

What real systems use

Most language standard libraries use a hybrid. Python's Timsort blends merge + insertion and exploits already-sorted runs — fast on real-world data, stable, O(n log n) worst case. C++ std::sort uses Introsort: quick → heap on bad pivots → insertion on small partitions. JavaScript's Array.prototype.sort is required to be stable since 2019; engines use Timsort or similar.

0
Score
0
Streak
%
Question