Algorithm dossier
- Category: Sort
- Worst-case complexity: O(n log n)
- Approach: Divide & conquer
- Data structure: Array
- First formalised: 1960s
Why this snippet is Quicksort
Why quicksort. Pick a value (x here — the midpoint sample, a common pivot heuristic), partition in-place so smaller items move left and larger move right, then recurse on each half. Hoare partition is identifiable by the two converging pointers i and j and the a[i], a[j] = a[j], a[i] swap when they cross. Confusable with. Mergesort also recurses on halves but merges *out-of-place*, not in-place.
How to read a redacted algorithm
Algodle strips identifier names so the snippet has to be read for its shape: the control flow, the data structures it manipulates, the order in which it visits its input. Loops with two pointers crawling toward each other are usually search or partition. A recursion that splits its input in half and recurses on both halves is divide-and-conquer. A priority queue plus graph traversal is almost certainly Dijkstra, Prim, or A*. Six hint columns — category, complexity, approach, data structure, era — let you triangulate even when the snippet itself is opaque.