Skip to content
Essays · Long-Form Notes

Slow thinking about algorithms.

A small set of long-form essays. Fewer than one per week, because each is written slowly. Topics range from interview patterns to the craft of explanation to the books that shaped this curriculum.

The essays here are intentionally different from the module pages. Modules are structured curriculum. They cover an entire data structure or pattern from first principles. Essays are arguments. They make a claim, defend it with examples, and sometimes annoy people who hold the opposite position. That's the point.

We publish on no schedule. A new essay appears when one is finished, not when a calendar says it should. Each piece goes through at least three drafts before publication; the goal is the writing density of a careful textbook chapter, not the cadence of a blog. If you want every essay delivered, the RSS feed picks up new pieces within an hour of publication.

Essays draw on the same engineering experience that informs the modules: production performance debugging, technical interviews from both sides of the table, and the specific cases where the textbook answer is wrong. They link freely back into the modules where the underlying technique gets a proper treatment. Read them in either order; the cross-references work both ways.

Three essays are currently live. Two more are in draft. If a topic interests you that isn't covered yet, the contact page is the right channel for requests. Topic suggestions land in the queue; not every one ships, but most do.

Featured essays

Featured · The Canon

DSA study plans that actually work

How long does it take to learn data structures and algorithms? Six to twelve weeks, if the plan matches your deadline. Here are the three study plans behind AlgoMastery's pathways,…

9 minPedagogy
Read essay
Essay · Patterns

What is the difference between memoization and tabulation

The difference between memoization and tabulation is direction: top-down caching of a recursion versus a bottom-up loop over a table. Here is what that changes in work done, stack …

Read →
Essay · Craft

What is a monotonic stack

What is a monotonic stack? A stack that stays sorted by popping anything that would break the order, which turns every next-greater-element question into one O(n) pass. Here is how…

Essay · Complexity

How to find the time complexity of a recursive function

A working method for finding the time complexity of a recursive function: write the recurrence, draw the call tree, and check it against the master theorem. Includes worked counts …

Essay · Complexity

Why is quicksort faster than merge sort?

Why is quicksort faster than merge sort when merge sort does fewer comparisons? A worked example with a million integers shows where the time goes: data movement, cache footprint a…

Essay · Complexity

Why is quicksort faster than merge sort in practice

Why is quicksort faster than merge sort in practice, when both are O(n log n) on average? Quicksort actually does more comparisons. It wins on memory traffic, footprint and loop ti…

Essay · Complexity

Why is heapify O(n) and not O(n log n)

Why is heapify O(n) when each sift-down can cost O(log n)? Because the work per node depends on its height, and half the nodes have height zero. Here is the counting argument with …

Essay · Craft

When to use prefix sum vs sliding window

Prefix sum vs sliding window is a choice about monotonicity and negative numbers, not about how the problem looks. Here is the test I use, with a worked example, operation counts, …

Essay · Craft

How to tell if a problem needs greedy or dynamic programming

Choosing between greedy or dynamic programming comes down to whether you can prove the first choice is safe. Here is a repeatable test, a worked coin change example with real numbe…

Essay · Complexity

Why does Dijkstra not work with negative edges

Why does Dijkstra not work with negative edges? It settles a node the moment it leaves the heap, and a negative edge can make a later path cheaper. Here is a four-node counterexamp…

Essay · Interviews

Is Python too slow for coding interviews?

Is Python too slow for coding interviews? Almost never, but there are three specific situations where it bites. Here are the real numbers, the operation budgets, and the fixes that…

Essay · Craft

What is the difference between sliding window and two pointers

The difference between sliding window and two pointers is what the pointers represent: a sliding window summarises a contiguous range, while two pointers discard candidate pairs. H…

Essay · Craft

When to use BFS vs DFS

When to use BFS vs DFS depends on what you need back: shortest steps, full exploration, or dependency order. Here is a decision rule, a worked grid example with real counts, and th…

Essay · Complexity

What is amortized time complexity

What is amortized time complexity? It is the cost per operation averaged over a worst-case sequence, which is why a dynamic array append is O(1) even though some appends copy the w…

Essay · Complexity

Why does my solution get time limit exceeded?

Why does my solution get time limit exceeded when the logic is right? Because the growth rate does not fit the input limit. Here is how to estimate operations, spot hidden O(n) cos…

Essay · Performance

Why is string concatenation in a loop slow

String concatenation in a loop is slow because immutable strings are copied in full on every append, which makes the total work quadratic. Here is the arithmetic, how Python, Java,…

Essay · Craft

Why is dynamic programming so hard?

Why is dynamic programming so hard? Because it is taught as a bag of solved problems when it is really a single skill: defining a state small enough to store and complete enough to…

Essay · Craft

Why is binary search so hard to get right?

Why is binary search so hard to get right? Because the idea is trivial and the boundaries are not: which interval you maintain, how you compute the midpoint, and when you stop each…

Essay · Data Structures

When should you use a heap instead of sorting?

When should you use a heap instead of sorting? When you need only the k smallest or largest, when items arrive over time, or when you repeatedly need the current minimum. Sorting p…

Essay · Performance

Is recursion slower than iteration?

Is recursion slower than iteration? Usually by a small constant, sometimes not at all, and occasionally catastrophically, when the recursion recomputes subproblems or exhausts the …

Essay · Performance

Why is my hash map slow?

Why is my hash map slow? Almost always one of four things: a bad hash function, a load factor allowed to climb, keys that are expensive to hash or compare, or cache misses from a m…

Essay · Interviews

How many LeetCode problems are enough?

How many LeetCode problems are enough before an interview? Around 100 to 150, chosen to cover the core patterns, beats 500 picked at random. The number that predicts your interview…

Essay · Interviews

Are brain teasers still asked in coding interviews?

Are brain teasers still asked in coding interviews? Big tech formally dropped them years ago, yet the reasoning they test never left: it just moved inside algorithm questions, esti…

Essay · Complexity Analysis

O(log n) vs O(n log n): what the difference actually means

The difference between O(log n) and O(n log n) is one question: does your algorithm have to touch every element? Binary search discards half the data and never reads most of it. Me…

Essay · Interview Preparation

Coding interview patterns: the 15 that keep coming back

Most coding interview patterns lists are just problem tags. This is a working catalogue: 15 patterns, the cue that identifies each one, the invariant it protects, what it costs, an…

Essay · Craft of Programming

Why your recursive solution works but you cannot explain it

Most developers can write a recursive function that passes tests. Far fewer can trace the call stack, name the invariant each frame maintains, or explain why the base case is suffi…

Essay · Performance

Why arrays beat linked lists in practice

Arrays beat linked lists in most real code, and the reason is the memory hierarchy, not Big-O. Here is the cache-locality argument, an honest benchmark sketch, and the short list o…

Essay · Engineering Taste

The Hidden Cost of Premature Abstraction

In algorithm design and in engineering generally, the most expensive bugs are not the ones we make, they are the abstractions we built before we understood the problem. This essay …

Essay · Pedagogy

The texts that taught me algorithms

A slow reading list: four books that did the heavy lifting when I was learning. What each does best, what each is bad at, and why their strengths don't overlap as much as a glance …

Essay · Pattern Recognition

Recognise the shape, not the problem

Interview problems reuse a small catalogue of shapes. The candidate who memorises two hundred problems is running a losing race against the candidate who can classify a new problem…

Essay · Reasoning

Complexity is a contract, not a fact

"O(n)" is not a measurement. It's a contract: a promise about how running time scales <em>given certain assumptions</em>. When those assumptions fail, the contract is void, and fas…

More essays arrive when they're ready. There is no schedule.