Skip to content

Algorithms Code Textbook

A free, self-paced textbook in 7 chapters. Read a chapter, then drill it with the 422 companion flashcards using spaced repetition.

7 chapters · 422 cards · Updated

Chapters

  1. 1Searching and Sorting Foundations

    This chapter covers the essential searching and sorting algorithms that form the backbone of algorithmic problem solving. Binary Search is the cornerstone searching technique on so...

  2. 2Array Techniques and Problem Patterns

    Several powerful techniques transform seemingly complex array problems into elegant linear-time solutions. The Two Pointers technique uses two indices moving toward each other or i...

  3. 3Trees and Hierarchical Structures

    Binary trees and Binary Search Trees (BSTs) form the foundation of hierarchical data structures. A BST maintains the invariant that left children are less than the parent and right...

  4. 4Graph Algorithms

    Graph traversal forms the basis of countless algorithms. Breadth-First Search (BFS) explores level by level using a queue, making it ideal for shortest path in unweighted graphs, l...

  5. 5Dynamic Programming

    Dynamic Programming solves problems by breaking them into overlapping subproblems and storing results to avoid recomputation. The Fibonacci example illustrates both approaches: top...

  6. 6Advanced Data Structures

    The heap (priority queue) is a complete binary tree maintaining the heap property. Min-heaps support O(log n) insert and extract-min, with O(1) peek. Python's heapq module implemen...

  7. 7String Algorithms and Specialized Techniques

    String matching algorithms efficiently find patterns within text. The naive approach runs in O(n × m), but sophisticated algorithms achieve linear or near-linear time. KMP (Knuth-M...

← Back to the Algorithms Code deck