Practical quicksort needs 3-way partitioning and recursion-depth detection
srchvrs · x · 2026-11-15
Replying to a nostalgia post featuring an old Pascal quicksort, search engineer srchvrs outlines what production-grade implementations actually do: three-way partitioning plus recursion-depth detection to catch degenerate cases (duplicate-heavy inputs, bad pivots) and fall back to a different algorithm. He notes most modern quicksort implementations work this way, and adds that he once hit pathological slowdowns with an old C++ stdlib sort and switched to merge sort for its guaranteed O(n log n).
More from coding & agent
- Proof of Agent goes viral: paste a prompt and let your AI agent mine POA — adamamcbride · 2026-11-15
- Google and Northwestern's Harness² self-improves agent harnesses without answer keys — rohanpaul_ai · 2026-11-15
- Dev builds a PowerShell AI harness for Microsoft's new Intelligent Terminal — dfinke · 2026-11-15
- snitch: a harness that watches agents in parallel and reverts bad paths — generativist · 2026-11-15
- Dev: unattended agent runs burn 99% of tokens on useless reproducibility gates — generativist · 2026-11-15
- workspace-cli: open-source Rust CLI for AI agents to drive Google Workspace — majidmanzarpour · 2026-11-15