Blog

Notes on data structures & algorithms, system design, and things I learn along the way.

Learning DSA? Follow the structured path — ordered articles from recursion to dynamic programming.→
October 16, 2026Strongly Connected Components: Kosaraju's Algorithm4 min read

In a directed graph, which groups of nodes can all reach each other? How two depth-first searches — one on the graph, one on its reverse — find every strongly connected component in linear time, why the finish order is the trick, and where SCCs show up: dependency cycles, 2-SAT, and condensing a graph into a DAG.

#DSA
October 10, 2026Sliding Window Maximum with a Monotonic Deque4 min read

The maximum of every window of size k in an array, in O(n) instead of O(n·k). How a deque of indices with decreasing values throws away elements that can never win, why every element is pushed and popped at most once, and where the same idea shows up.

#DSA
October 10, 2026The 0/1 Knapsack Problem, Step by Step4 min read

Pick items with weights and values to maximise value without going over a capacity, using each at most once. Why greedy fails, how a table of 'best value with these items and this capacity' solves it, how to recover the chosen items, and the one-array version that iterates backwards.

#DSA
October 9, 2026Edit Distance: How Spell-Checkers Measure 'Close Enough'3 min read

The fewest inserts, deletes and substitutions to turn one word into another. How the Levenshtein distance is computed with a small DP table, how to recover the actual edits, and where it's used — from 'did you mean' to fuzzy search and DNA alignment.

#DSA
October 9, 2026Floyd–Warshall: Shortest Paths Between Every Pair of Nodes3 min read

Dijkstra answers 'how far from here to everywhere'. Floyd–Warshall answers 'how far from everywhere to everywhere' — with three nested loops and one table. How the via-vertex idea works, how to rebuild the paths, and when it beats running Dijkstra many times.

#DSA
October 8, 2026Kadane's Algorithm: The Maximum Subarray in One Pass3 min read

Find the contiguous slice of an array with the largest sum — in O(n) time and O(1) memory. Why a negative running sum should always be dropped, how to recover the slice itself, and how the same idea solves stock prices, circular arrays and products.

#DSA
October 6, 2026Hash Functions Explained: Turning Anything Into a Number4 min read

A hash function maps any input to a fixed-size number, the same input always to the same number. How a simple one works, why collisions are unavoidable, what makes a hash good, and how the same idea powers hash maps, caches and passwords.

#DSA
September 27, 2026Rabin-Karp and the Rolling Hash5 min read

Compare a fingerprint of each window instead of the window itself — and update that fingerprint in O(1) as the window slides. The string-matching algorithm that also powers plagiarism detection, rsync, and content-defined chunking.

#DSA
September 26, 2026Bellman-Ford: Shortest Paths When Edges Can Be Negative4 min read

Dijkstra locks in a node the moment it's popped, which is exactly what breaks when an edge weight is negative. Bellman-Ford gives up that greed, relaxes every edge V − 1 times, and can tell you when no shortest path exists at all.

#DSA
September 26, 2026Quickselect: The kth Smallest Element in Linear Time4 min read

Quicksort recurses into both halves. Quickselect recurses into one — and that single change drops the expected cost from O(n log n) to O(n). How it works, why it's linear, and when a heap is the better call.

#DSA

51 posts tagged DSA · page 2 of 6