Notation
This section summarizes the mathematical and typographical conventions used throughout the book. It is intended as a reference; each symbol is introduced and explained in context when it first appears.
Asymptotic notation
| Symbol | Meaning |
|---|---|
| Asymptotic upper bound: for all (Definition 2.2) | |
| Asymptotic lower bound: for all (Definition 2.3) | |
| Tight bound: and (Definition 2.4) | |
| Strict upper bound: as | |
| Strict lower bound: as |
The asymptotic families correspond loosely to the comparison operators: to , to , to , to , and to .
Common growth rates
| Growth rate | Name | Example algorithm |
|---|---|---|
| Constant | Hash table lookup (expected) | |
| Logarithmic | Binary search | |
| Linear | Finding the maximum | |
| Linearithmic | Merge sort, heap sort | |
| Quadratic | Insertion sort (worst case) | |
| Cubic | Floyd-Warshall | |
| Exponential | Subset sum (brute force) | |
| Factorial | TSP (brute force) |
General mathematical notation
| Symbol | Meaning |
|---|---|
| Input size (unless otherwise stated) | |
| Running time as a function of input size | |
| Floor: largest integer | |
| Ceiling: smallest integer | |
| Logarithm base 2 (unless base is stated explicitly) | |
| Logarithm base | |
| Natural logarithm (base ) | |
| -th harmonic number: | |
| Factorial: | |
| Binomial coefficient: | |
| Remainder when is divided by | |
| Summation of for from to | |
| Product of for from to | |
| Infinity | |
| Approximately equal |
Logic and quantifiers
| Symbol | Meaning |
|---|---|
| Implies (if ... then) | |
| If and only if | |
| For all | |
| There exists |
Set notation
| Symbol | Meaning |
|---|---|
| Set containing elements , , | |
| is a member of set | |
| is not a member of set | |
| is a subset of (possibly equal) | |
| is a proper subset of | |
| Union of and | |
| Intersection of and | |
| Set difference: elements in but not in | |
| Cardinality (number of elements) of set | |
| Empty set | |
| Set of real numbers | |
| Set of all binary strings |
Graph notation
| Symbol | Meaning |
|---|---|
| Graph with vertex set and edge set | |
| Number of vertices | |
| Number of edges | |
| Edge from vertex to vertex | |
| Weight of edge | |
| Weight function mapping edges to real numbers | |
| Shortest-path weight from to | |
| Distance between vertices and | |
| Capacity of edge (in flow networks) | |
| Flow on edge | |
| Total weight of tree | |
| Adjacency list of vertex |
Vertices are typically denoted by lowercase letters: , , (source), (sink). We use to denote a path from to .
Probability notation
| Symbol | Meaning |
|---|---|
| Probability of event | |
| Expected value of random variable |
Complexity classes
Complexity classes are set in bold: , , . NP-complete problems are written in small capitals in running text (e.g., SUBSET SUM, SAT, HAMILTONIAN CYCLE).
Algorithm and function names
In mathematical expressions, algorithm names are typeset in roman (upright) text to distinguish them from variables:
- , , for heap index calculations
- for shortest-path edge relaxation
- for the optimal solution value on instance
Running-time recurrences use . Fibonacci numbers are .
Array and indexing conventions
All TypeScript implementations use 0-based indexing: the first element of an array arr is arr[0], and an array of elements has indices .
In mathematical discussion, array ranges are written as to denote the subarray from index (inclusive) to (exclusive). In heap formulas:
Formal structures
Formal definitions, theorems, and lemmas are set in blockquotes with a label:
Definition X.Y --- Title
Statement of the definition.
Proofs end with the symbol . Examples are labeled Example X.Y and numbered within each chapter.
Code conventions
- All code is TypeScript with strict mode and ES module syntax.
- Generic type parameters (e.g.,
T,K,V) follow standard TypeScript conventions. - The shared type
Comparator<T>is(a: T, b: T) => number, returning negative if , zero if , and positive if . - Code snippets in chapters match the tested implementations in the
src/directory.