Algorithm dossier
- Category: Sort
- Worst-case complexity: O(n log n)
- Approach: Divide & conquer
- Data structure: Array
- First formalised: 1940s
Why this snippet is Merge Sort
Why merge sort. Halve at m, recurse on each half, then *zipper* the two sorted halves together with two index pointers. The unmistakable tail (out.concat(x.slice(i)).concat(y.slice(j))) drains whichever side has leftovers. Distinguishing. Quicksort also halves recursively but partitions in-place before recursing — it never builds a merged copy.
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.