SARATH THARAYILST
WRITEUPSCONCEPTSPROJECTSLABABOUT
SARATH THARAYIL
മ
IGARATIPO: AMAZON TRIBUTARIES
/ SYSTEM

Building thoughtful software, writing notes, and shipping experiments across data, AI, and the web.

No cookies, no tracking. Preferences are stored locally in your browser. Anonymous view counts are kept server-side.

Hey, there's a story for the river above/© 2026 Sarath Tharayil/IST --:--:--
← LAB

Sorting Algorithms

Jun 6, 2026

Four algorithms, one array. Every comparison and swap is rendered as a bar chart frame. Bubble sort is satisfyingly terrible. Merge sort divides and conquers in clean halves. Quick sort partitions around pivots. Heap sort builds an order without extra memory.

N80
SPEED5
0 ops

Orange = active comparison. Accent = sorted. Speed=1 to follow individual swaps.

/ NOTES
ALGORITHMS
Bubble O(n²)Repeatedly steps through, swapping adjacent out-of-order elements. Simple. Slow.
Merge O(n log n)Recursively divides into halves and merges them sorted. Stable, predictable.
Quick O(n log n)Partitions around a pivot. Average-case fast; worst-case O(n²) on sorted input.
Heap O(n log n)Builds a max-heap, extracts the maximum repeatedly. In-place, not stable.
WHAT TO TRY

Set input to Nearly Sorted and watch quick sort struggle while merge sort breezes through. Slow the speed right down to follow individual comparisons. Increase array size to see O(n²) versus O(n log n) diverge visually.