This subject is usually taught as a catalogue to memorise, which is why people can recite that a hash lookup is constant time and still pick the wrong structure. The useful version is a decision procedure: what does this code do most, what does that cost as the data grows, and where does the guarantee stop holding. Every claim below was measured, not recalled.
Each chapter opens with the short version. Tap one to read the detail.
The machine underneath: indices, recursion, bits
~2 min
An array is fast for one reason: element k sits at an address you can compute, reached without touching the others. Recursion is the mirror image — each call is a real stack frame.
Complexity describes growth, not speed
~2 min
Big-O says how cost grows, not how fast code is — it discards the constants that often decide at real sizes. Amortised cost promises a worst case over a sequence, not an average.
Arrays, lists, and what your library actually costs
~2 min
Stack, queue and deque are contracts; array and linked list are implementations. Pick by the operation you do most — the same data in two containers can differ by three orders of magnitude.
Sorting, end to end
~2 min
Merge sort is stable and needs n extra space; quicksort is in-place, unstable, and goes quadratic on ordered input. No comparison sort beats n log n; counting and radix sorts do, by not comparing.
Priority queues: the cheapest "what's next?"
~2 min
A heap gives you the extreme element cheaply and nothing else. It is not sorted — it is an array where index arithmetic replaces pointers.
Search trees, and why balance is the whole game
~2 min
A symbol table maps keys to values, and the only question that matters is whether you need them ordered. A search tree gives order — but every operation costs its height, and sorted keys make it n.
Hash tables: average O(1), and how it stops being true
~2 min
A hash table is an array plus a function turning a key into an index. Its constant time is an average, broken by three things: a crowded table, a bad hash, mutated keys.
Graphs: the model first, then the two searches
~2 min
Most graph problems stop being exotic once you name the vertices and edges. Then there are two searches, and choosing is not taste — one answers your question and the other does not.
Greedy on graphs: spanning trees and connectivity
~2 min
A minimum spanning tree connects every vertex at the lowest total edge weight. It is one of the few places greed is provably correct, and the proof is one property about edges crossing a cut.
Shortest paths, and the assumption that breaks silently
~2 min
Every shortest-path algorithm makes the same move — improve an estimate along one edge — differing only in order. Dijkstra's is valid only when no edge is negative; violate that and it quietly returns a wrong answer.
Dynamic programming, and when greed is enough
~2 min
Dynamic programming is recursion plus remembering. It pays off when a problem has optimal substructure and overlapping subproblems — the second is what makes it a win. Greedy claims more, and needs proof.
Scanning: pointers, windows, prefixes
~2 min
The nested loop is the default and usually replaceable: when the data is ordered, or the quantity you track moves one way, one pass with two indices does the same job.
When no algorithm will save you
~2 min
Some problems have no algorithm at all — not slow ones, none. Others are only believed hard: no fast method is known, and they are all interconvertible.
Written by Keentune. We are not affiliated with or endorsed by the organizations whose documentation informs this guide, and any linked sources belong to their respective owners.
All exam, test, and product names and trademarks are the property of their respective owners and are used here for identification and reference only. Keentune is independent study practice — not affiliated with, authorized, or endorsed by any of these organizations.