Skip to main content

Algorithms & Data Structures

Everything below this point in the knowledge base is about what the machine can do. This section is about what to ask it to do. The distinction matters because the gap between a good algorithm and a bad one is not a constant factor you can buy your way out of with faster hardware — a quadratic algorithm on a million items loses to a linearithmic one by roughly fifty thousand times, and no CPU upgrade in history has ever been worth fifty thousand times.

How this section is organised

Complexity & Analysis first, because it is the vocabulary every other page uses. Then Data Structures, because the choice of structure usually determines which algorithms are even available to you. Then the classic algorithm families — Sorting, Searching, Graph Algorithms — and finally Problem-Solving Patterns, the recurring shapes that show up across all of them.

Sections

SectionWhat it covers
Complexity & AnalysisBig-O and friends, growth rates, amortized and space complexity
Data StructuresArrays, linked lists, stacks/queues, hash tables, trees, heaps, graphs
Sorting AlgorithmsBubble, selection, insertion, merge, quick, heap — and how to choose
Searching AlgorithmsLinear and binary search, and what each one costs you up front
Graph AlgorithmsBFS/DFS traversal, shortest paths, topological sorting
Problem-Solving PatternsTwo pointers, sliding window, divide & conquer, greedy, DP, backtracking

Why this sits inside Computer Science

The rest of this knowledge base explains the machine that runs these algorithms, and the connection is not decorative. Several results here only make sense in light of it:

  • Binary search beats linear search asymptotically but not always in practice on small arrays, because linear search is cache-friendly and binary search jumps around.
  • Hash tables are O(1) on paper and can still be slow, for the same reason — see the load-factor curves on the hash tables page.
  • B-trees exist instead of binary trees in databases purely because of storage access granularity, not because of anything algorithmic.
  • Quicksort usually beats mergesort despite identical average complexity, largely because it sorts in place and touches memory sequentially.

An algorithm's complexity class tells you how it scales. The machine underneath tells you what it costs. You need both.

Suggested Reading Path

References

  • Cormen, Leiserson, Rivest & Stein, Introduction to Algorithms (CLRS) — the standard reference; rigorous, and the source most other treatments are derived from.
  • Sedgewick & Wayne, Algorithms, 4th ed. — more approachable, with excellent visualisations.
  • GeeksForGeeks — Data Structures and Algorithms — broad catalogue of individual algorithms with implementations.

Books & Videos

  • Sedgewick & Wayne, Algorithms, Part I — the companion course to the book, free to audit.
  • VisuAlgo — interactive, step-by-step animations of most structures and algorithms on these pages.
  • Memory Hierarchy & RAM — why constant factors and access patterns matter as much as complexity class.
  • Databases — B-trees, LSM-trees and query planning are algorithm choices under commercial pressure.