Optimizing an Algorithm That’s Quadratic by Design
Summary
WhatChord's real-time chord naming uses ranking rather than a straightforward lookup. The article explains why a non-transitive ranking prevents ordinary sorting and how gating, Copeland-style tie-breaks, and per-pair optimizations reduce the O(n^2) cost. It also discusses the product implications of pruning and how a safe 3.0 ranking margin achieves large speedups while preserving user-visible results.