A free, self-paced textbook in 7 chapters. Read a chapter, then drill it with the 422 companion flashcards using spaced repetition.
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...
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...
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...
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...
Dynamic Programming solves problems by breaking them into overlapping subproblems and storing results to avoid recomputation. The Fibonacci example illustrates both approaches: top...
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...
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...