Algorithm dossier
- Category: Search
- Worst-case complexity: O(n)
- Approach: Iterative
- Data structure: Array
- First formalised: 1940s
Why this snippet is Linear Search
Why linear search. One pass, early-return on match. Trivial — but it's the only correct answer if a is unsorted. Why bother teaching it. Big-O literature uses it as the reference baseline: O(n) lookup; binary search beats it iff a is sorted; hashing beats it iff you can afford the hash table. The presence of *no preprocessing* fixes the answer at "linear scan."
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.