Randomized Quicksort, 15 Languages

CSC 482 — Homework 3: language comparison. Same algorithm (CLRS's RANDOMIZED-QUICKSORT), same timing protocol, one implementation per language, benchmarked on the same machine.

See the results → Read the methodology

Line graph of time vs n for all 15 languages

At a glance

Every language ran the same in-place, randomly-pivoted quicksort, doubling n each iteration starting at 1,000, until a single iteration exceeded 4.0 seconds. Fastest to slowest at the largest shared n each language reached:

LanguageMax n reachedTime at max n
C++65,536,0005.45 s
C65,536,0005.59 s
Zig65,536,0005.59 s
Assembly65,536,0005.95 s
Rust65,536,0005.88 s
F#65,536,0005.87 s
Go65,536,0006.71 s
C#65,536,0006.44 s
Java65,536,0007.81 s
Common Lisp65,536,0008.80 s
Pascal65,536,0009.29 s
PHP8,192,0008.24 s
TypeScript32,768,0004.04 s
Python2,048,0005.00 s
JavaScript65,536,00013.36 s

Full discussion, anomalies (JIT warmup, GC pauses, a JavaScript large-n outlier), and CPU details are in the results & comparison page.

Explore