Algorithm dossier
- Category: Graph
- Worst-case complexity: O(n)
- Approach: Iterative
- Data structure: No DS
- First formalised: 1960s
Why this snippet is Floyd's Cycle Detection
Why tortoise-and-hare. Two pointers walking the same linked list, but f (fast) advances *twice* per step while s (slow) advances once. On any cycle, the fast pointer eventually laps the slow one and they meet inside the loop. On a finite acyclic list, f runs off the end (null) first. Why O(1) space. No visited-set needed — the relative speed of two pointers is the entire data structure.
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.