Glossary
Every term the course defines, with the module that introduces it.
#
- 0-1 BFS
- Breadth-first search with a deque instead of a queue, for graphs whose edges weigh 0 or 1, pushing a weight-0 neighbor to the front and a weight-1 neighbor to the back.
Introduced in M5.9 BFS variants: multi-source, 0-1 BFS, zero-cost moves, reverse graph
A
- accumulator
- A variable that carries a running result forward through a loop, updated once per item.
Introduced in M2.4 Accumulator patterns
- adjacency list
- A way to store a graph as a list or dictionary that maps each vertex to the list of its neighbors.
Introduced in M4.12 Graphs I: modelling and adjacency lists
- adjacency matrix
- A way to store a graph as a 2D grid where entry [i][j] says whether an edge connects vertex i and vertex j.
Introduced in M4.12 Graphs I: modelling and adjacency lists
- algorithm
- A precise, step-by-step method for solving a problem.
- aliasing
- Two names that refer to the exact same list or other mutable value, so a change made through one name shows up when the other is read.
Introduced in M2.8 Debugging
- assignment
- Storing a value under a variable name using the equals sign.
Introduced in M1.1 Values, types, variables and
print - augmented assignment
- A shorthand such as
+=that updates a variable using its own current value in one step.Introduced in M1.2 Integer arithmetic and operators
B
- Back edge
- An edge in a DFS that points to an ancestor still on the stack. In a directed graph, a back edge closes a cycle, and a graph with no back edge has no cycle.
Introduced in M6.4 DFS tree properties
- backtracking
- Building a solution one choice at a time, trying each candidate that is still available, and undoing a choice the moment it cannot lead to a valid solution.
Introduced in M4.10 Backtracking search with pruning
- binary lifting
- A table that stores where you land after 1, 2, 4, 8, ... jumps from every node, so any number of jumps is answered by combining one table entry per set bit of the jump count.
Introduced in M6.12 Doubling and binary lifting on sequences
- binary search
- An algorithm that repeatedly halves a search space, keeping only the half that could still hold the target, to find a position or a value in O(log N) steps.
Introduced in M5.5 Binary search
- binary search on the answer
- Binary search applied to the value being sought itself, narrowing a range of candidate values with a feasibility check instead of comparing array entries.
Introduced in M5.5 Binary search
- binomial coefficient
- The number of ways to choose r items from n when the order of the choice does not matter, written C(n, r) and computed in Python by math.comb.
Introduced in M6.9 Counting and combinatorics
- boolean operator
- An operator that combines or inverts boolean values, such as
and,or, andnot.Introduced in M1.4 Booleans and conditionals
- breadth-first search
- A graph traversal algorithm that explores vertices level by level in order of distance from the source.
Introduced in M4.13 BFS and flood fill (iterative)
- brute force
- Solving a problem by checking every candidate answer directly, with no shortcut.
Introduced in M2.5 Brute force and complete search
C
- call stack
- The stack of frames for every function call currently in progress, most recent on top.
Introduced in M1.14 Recursion fundamentals
- ceiling division
- Division that rounds a result up to the next whole number when there is a remainder, computed as
-(-a // b).Introduced in M1.12 Floats, precision and big integers
- center expansion
- Finding the longest palindrome around a center by comparing outward one step at a time, stopping at the first mismatch or the string's edge.
Introduced in M5.12 O(N^2) DP on intervals and centre expansion
- circular array
- An array whose index wraps from the last element back to the first, usually with the modulo operator.
Introduced in M4.15 Circular arrays
- comparison operator
- An operator that compares two values and gives back a boolean, such as
==,<, orin.Introduced in M1.4 Booleans and conditionals
- complementary counting
- Counting the cases you want as the total number of cases minus the cases you do not want, when the unwanted cases are easier to count.
Introduced in M6.9 Counting and combinatorics
- conditional expression
- A one-line either/or expression of the form
a if condition else b, which evaluates toaorbdepending on the condition.Introduced in M1.4 Booleans and conditionals
- constructive problem
- A problem solved by building one valid answer directly and checking it against every rule, rather than searching a space of candidates.
Introduced in M5.1 Constructive problem solving
- convex function
- A function whose rate of change never decreases as its input grows, so any local minimum is also its single global minimum.
Introduced in M5.6 Convex functions: ternary search and slope sweep
- coordinate compression
- Mapping large coordinate values to small ranks to enable dense array storage for sparse 2D problems.
Introduced in M6.8 Coordinate compression and sweep line
- Cross edge
- A non-tree edge in a DFS of a directed graph that points to a finished node that is neither an ancestor nor a descendant, in a branch that closed earlier.
Introduced in M6.4 DFS tree properties
- cycle detection
- Recording the step at which each state first appears, so the first repeated state shows where a sequence starts looping and how long the loop is.
Introduced in M7.6 Number theory II
D
- degree
- The number of edges touching a node.
Introduced in M5.8 Trees I: rooting, parent/order arrays, pruning and diameter
- depth-first search
- A graph traversal that dives down one branch from a vertex before backtracking to try another, in contrast to breadth-first search's level-by-level order.
Introduced in M5.7 Iterative DFS and recursion elimination
- difference array
- An array storing the differences between consecutive elements, used to apply multiple range updates in O(1) time per update.
Introduced in M4.4 Difference arrays and interval clamping
- Dijkstra's algorithm
- An algorithm that finds the shortest path from a start node to all other nodes in a graph with non-negative edge weights.
Introduced in M6.1 Dijkstra's shortest paths
- disjoint set union
- A data structure that tracks which elements belong to the same group, supporting fast union and connectivity queries.
Introduced in M5.10 Disjoint Set Union (union-find)
- double-ended queue (deque)
- A data structure that adds and removes elements at both ends in constant time, such as Python's collections.deque.
Introduced in M4.8 Stacks and queues
- dynamic programming
- Solving a problem by filling in the answers to its smaller subproblems in a fixed order, each one built from subproblems already filled in, instead of computing them on demand through recursion.
Introduced in M4.11 Memoization and introductory dynamic programming
E
- edge
- A connection between two vertices in a graph, sometimes carrying a weight.
Introduced in M4.12 Graphs I: modelling and adjacency lists
- edge case
- An input at the extreme or unusual end of what a problem's bounds allow, such as the smallest size, every value equal, or a tie.
Introduced in M2.6 Case analysis and edge cases
- exchange argument
- A proof that a greedy order is optimal, showing that swapping two neighbors that the greedy rule would place the other way never makes the cost higher.
Introduced in M7.4 Exchange arguments, scheduling and greedy proofs
- expected value
- The average result of a random process, found by adding each possible outcome's value times its chance.
Introduced in M7.5 Probability and expected value
F
- Fenwick tree
- An array in which each position stores the sum of a block of elements whose length is the position's lowest set bit, so a point update and a prefix-sum query each take O(log n) steps.
Introduced in M6.10 Fenwick tree (Binary Indexed Tree)
- flood fill
- An algorithm that identifies and visits all connected cells matching a condition in a 2D grid.
Introduced in M4.13 BFS and flood fill (iterative)
- floor division
- Division that rounds the exact answer down to a whole number, written
//.Introduced in M1.2 Integer arithmetic and operators
- Forward edge
- A non-tree edge in a DFS of a directed graph that points to a finished descendant of the current node, one the search reached by another route.
Introduced in M6.4 DFS tree properties
- frequency array
- An array where each index stands for a possible value and the stored number is how many times that value has appeared.
Introduced in M3.6 Frequency arrays and counting
G
- generator expression
- The same shape as a list comprehension without square brackets, producing values one at a time instead of building a whole list.
Introduced in M1.8 Lists (1D and 2D)
- greatest common divisor
- The largest number that divides two given numbers with no remainder, written gcd.
Introduced in M4.6 Number theory I
- greedy algorithm
- An algorithm that solves a problem by making locally optimal choices at each step without reconsidering earlier decisions.
Introduced in M4.2 Sorting with keys, and greedy
- greedy choice property
- A property of optimization problems where a globally optimal solution always includes a locally optimal (greedy) choice made at the first step.
Introduced in M4.2 Sorting with keys, and greedy
- grid
- A rectangular layout of rows and columns, stored in Python as a list of rows, so that grid[row][col] reaches one cell.
Introduced in M3.7 Grid basics
H
- hash collision
- Two different inputs that produce the same hash value. Rare with a good hash and a large modulus, but never impossible.
Introduced in M5.4 Hashing: polynomial rolling hash
- hash-based lookup
- Storing and retrieving values by key through a hash function, so a lookup costs about the same regardless of how many keys are stored.
Introduced in M4.1 Hash-based lookup
- heap
- A complete binary tree stored in a list, where every parent is no bigger (min-heap) or no smaller (max-heap) than its children, giving fast access to the smallest or largest item.
Introduced in M5.11 Heaps and lazy deletion; ordered-set substitutes
I
- interpreter
- The program that reads Python source code and runs it, one instruction at a time.
Introduced in M0.1 What a program is
- interval clamping
- Clipping a range's endpoints to an array's valid indices, and skipping the update entirely if nothing of the clipped range remains, before applying it.
Introduced in M4.4 Difference arrays and interval clamping
- Interval DP
- A dynamic programming technique where subproblems are defined on contiguous intervals of a sequence, solved bottom-up by increasing interval length.
Introduced in M6.6 Interval DP and O(n³) algorithms
- invariant
- A quantity that stays the same no matter which allowed operation is applied, often used to show that a target state cannot be reached.
Introduced in M4.5 Mathematical insight: parity, invariants, closed forms
L
- lazy deletion
- An optimization technique where items are marked invalid instead of being removed immediately, with removal deferred until they are popped.
Introduced in M5.11 Heaps and lazy deletion; ordered-set substitutes
- lazy propagation
- Recording a range update as a pending tag on the few segment tree nodes that cover the range, and pushing the tag down to their children only when a later operation needs to look inside.
Introduced in M7.2 Lazy propagation
- leaf
- A node of degree 1 in a tree with more than one node.
Introduced in M5.8 Trees I: rooting, parent/order arrays, pruning and diameter
- least common multiple
- The smallest positive number that two given numbers both divide evenly, written lcm.
Introduced in M4.6 Number theory I
- linearity of expectation
- The rule that the expected value of a sum is the sum of the expected values, even when the pieces depend on each other.
Introduced in M7.5 Probability and expected value
- list comprehension
- A one-line way to build a list from an existing sequence, written
[expression for name in sequence], optionally filtered withif.Introduced in M1.8 Lists (1D and 2D)
- local
- A variable that exists only inside the function call that created it, separate from any variable of the same name outside that function.
Introduced in M1.10 Functions and scope
- lookup table
- A precomputed mapping from a key or index to its answer, built once and read directly instead of recomputed.
Introduced in M3.5 Lookup tables
- lowest common ancestor
- In a rooted tree, the deepest node that is an ancestor of both of two given nodes, where a node counts as its own ancestor.
Introduced in M7.13 LCA and binary lifting on trees
M
- matches counter
- A running count of how many tracked quantities currently equal their target, updated incrementally so a match can be checked in O(1) instead of comparing every quantity.
Introduced in M5.3 Sliding windows with counts
- memoization
- Storing the result of each distinct call to a recursive function the first time it runs, so a later call with the same arguments is looked up instead of recomputed.
Introduced in M4.11 Memoization and introductory dynamic programming
- method
- A function called on a value using a dot, such as
.split()called on a string.Introduced in M1.3 Reading input
- Minimum spanning tree
- A spanning tree of a graph with the smallest total edge weight. A spanning tree connects all n nodes with n - 1 edges and no cycle.
Introduced in M6.3 Minimum spanning tree: Kruskal plus DSU
- modular inverse
- For a and a modulus m, the number x with a * x leaving remainder 1 after division by m. It exists when gcd(a, m) is 1, and multiplying by it stands in for dividing by a.
Introduced in M7.6 Number theory II
- modulo
- The remainder left over after floor division, written
%.Introduced in M1.2 Integer arithmetic and operators
- monoid
- A way of combining two values that is associative (grouping never changes the result) and has an identity value that changes nothing when combined with anything, such as addition with 0 or minimum with a huge number.
Introduced in M7.1 Segment tree (iterative, custom merge)
- monotonic deque
- A double-ended queue of indices whose values stay sorted from front to back, popping weaker entries from the back and expired ones from the front, so the front is always a sliding window's maximum or minimum.
Introduced in M6.11 Monotonic stack and deque
- monotonic stack
- A stack whose entries stay in one sorted direction because larger or smaller entries are popped before each push, used to find the nearest greater or smaller neighbor in linear time.
Introduced in M6.11 Monotonic stack and deque
- multi-source BFS
- Breadth-first search started from several nodes at once, all at distance 0, so it finds each node's distance to its nearest source in one pass.
Introduced in M5.9 BFS variants: multi-source, 0-1 BFS, zero-cost moves, reverse graph
- multiple assignment
- Assigning several values to several names in one line, matched left to right by position.
Introduced in M1.3 Reading input
- multiset
- A collection that allows the same value to appear more than once, while still supporting fast queries such as the current maximum.
Introduced in M5.11 Heaps and lazy deletion; ordered-set substitutes
O
- online algorithm
- An algorithm that must answer each query before it can read the next, which happens when the next query is decoded from the previous answer, so the queries cannot be sorted or batched.
Introduced in M7.11 Online algorithms and encrypted input
- operator
- A symbol such as
+or//that performs a computation on one or more values.Introduced in M1.2 Integer arithmetic and operators
P
- path halving
- An optimization in the find operation where each node points to its grandparent instead of its parent, flattening the tree over time.
Introduced in M5.10 Disjoint Set Union (union-find)
- periodicity
- The property of a sequence that repeats the same pattern of values after a fixed number of steps, called its period.
Introduced in M3.8 Clock and calendar arithmetic, modulo and periodicity
- postorder
- A traversal order where a vertex is recorded only after all of its descendants have been visited.
Introduced in M5.7 Iterative DFS and recursion elimination
- precedence
- The fixed order in which Python runs the operators in a line that has more than one. Parentheses change that order.
Introduced in M1.2 Integer arithmetic and operators
- prefix sum
- An array where each element stores the running total of all values up to, but not including, that index, so the sum of any range can be found with one subtraction.
Introduced in M4.3 Prefix sums (1D, 2D, prefix/suffix max)
- preorder
- A traversal order where a vertex is recorded before any of its descendants are visited.
Introduced in M5.7 Iterative DFS and recursion elimination
- prime number
- A whole number greater than 1 with exactly two divisors, itself and 1.
Introduced in M4.6 Number theory I
- priority queue
- A data structure that retrieves the item with the smallest (or largest) priority key first.
Introduced in M6.1 Dijkstra's shortest paths
- pruning
- Skipping a branch of a search once it is clear that no candidate built from it can pass, without changing which candidates would otherwise be found.
Introduced in M4.10 Backtracking search with pruning
Q
- queue
- A first-in, first-out data structure where elements are added at the back and removed from the front.
Introduced in M4.8 Stacks and queues
- quickselect
- Finding the value at a given sorted position by splitting the list around a pivot and keeping only the group that must hold that position.
Introduced in M5.13 Randomized strategies
R
- randomized algorithm
- An algorithm that makes random choices, such as shuffling or picking a random pivot, so its running time or its chance of success depends on those choices.
Introduced in M5.13 Randomized strategies
- reassignment
- Binding an existing variable name to a new value.
Introduced in M1.1 Values, types, variables and
print - recursion
- A function calling itself to solve a smaller version of the same problem.
Introduced in M1.14 Recursion fundamentals
- rerooting
- Computing a rooted answer for every node as the root in two passes, one bottom-up and one top-down, by correcting each parent's answer for the single edge that changes when the root moves to a child.
Introduced in M6.5 Tree DP
- reverse-graph BFS
- Breadth-first search run once from a target over every edge reversed, giving each node's distance to that target instead of from a source.
Introduced in M5.9 BFS variants: multi-source, 0-1 BFS, zero-cost moves, reverse graph
- rolling hash
- A hash of a fixed-length window that updates in O(1) per slide, instead of being recomputed from scratch at every position.
Introduced in M5.4 Hashing: polynomial rolling hash
- run-length encoding
- A way to compress a string by replacing each run of identical characters with its length followed by the character.
Introduced in M3.3 String processing I: counting, runs and building
S
- segment tree
- A tree data structure that stores partial answers about ranges, enabling point updates and range queries in logarithmic time.
Introduced in M7.1 Segment tree (iterative, custom merge)
- sieve of Eratosthenes
- An algorithm that finds every prime up to a limit by marking off the multiples of each prime it finds, starting from that prime's square.
Introduced in M4.6 Number theory I
- simulation
- Solving a problem by running its described process step by step, with a variable for each piece of state.
Introduced in M2.3 Simulation
- sliding window
- A two-pointer technique where the pointers mark the ends of a contiguous range that grows and shrinks as it scans, instead of jumping independently.
Introduced in M5.3 Sliding windows with counts
- slope sweep
- An algorithm that finds the minimum of a sum of piecewise-linear terms by processing their breakpoints in sorted order, updating the total slope incrementally at each one.
Introduced in M5.6 Convex functions: ternary search and slope sweep
- small-case enumeration
- Finding a pattern by running a slow, obviously correct method on many small inputs, tabulating the results, and turning what repeats into a fast rule.
Introduced in M5.2 Pattern discovery by small-case enumeration
- source code
- The plain text you write that describes what you want a program to do, before anything runs it.
Introduced in M0.1 What a program is
- sparse table
- A precomputed table for answering idempotent range queries (minimum, maximum, gcd) in constant time after O(N log N) preprocessing.
Introduced in M7.3 Sparse table
- Sparsification
- Keeping only the part of a graph or state space that a search needs. The search builds just the states it can reach from the start, and a map can be shrunk to its key nodes joined by shortest distances, instead of building every possible state and edge.
Introduced in M6.2 State-space graph modelling and sparsification
- sqrt decomposition
- Cutting an array into blocks of about the square root of its length and keeping one stored summary per block, so a range query reads two partial blocks plus whole-block summaries and a point update fixes one value and one summary.
Introduced in M7.9 Sqrt decomposition
- stack
- A last-in, first-out data structure where every addition and removal happens at the same end.
Introduced in M4.8 Stacks and queues
- standard input
- The stream of text a program reads its input from, normally whatever the judge feeds it.
Introduced in M0.4 The standard input/output model and exact output
- standard library
- The collection of modules that ships with Python itself, without installing anything extra.
Introduced in M1.13 Imports and the standard library tour
- standard output
- The stream of text a program writes its output to, normally what the judge reads and compares.
Introduced in M0.4 The standard input/output model and exact output
- stress test
- Running a fast solution and a slow, trusted one on many small random inputs and comparing their answers, to find an input where the fast one is wrong.
Introduced in C.6 Stress testing against a brute force
- subtask
- A named group of hidden test cases within one problem, run and reported together as a batch.
Introduced in M0.5 How judging works
- subtree
- In a rooted tree, a node together with everything reachable from it without passing back through its parent.
Introduced in M5.8 Trees I: rooting, parent/order arrays, pruning and diameter
- sweep line
- A technique that walks the start and end events of intervals or shapes in sorted order, updating a running state such as how many intervals are open, so that each stretch between two events is handled at once.
Introduced in M6.8 Coordinate compression and sweep line
T
- ternary search
- A search that narrows an interval known to contain the minimum (or maximum) of a unimodal function by comparing its value at two interior points each round.
Introduced in M5.6 Convex functions: ternary search and slope sweep
- tokenize
- Split a string into individual pieces, called tokens, using a delimiter or a rule.
Introduced in M3.4 String processing II: tokenizing with state
- traceback
- The message Python prints when a program stops with an error, naming the file, the line, and the error itself.
Introduced in M0.6 Reading error messages
- transpose
- Swap a grid's rows and columns, so the cell at row r, column c moves to row c, column r.
Introduced in M4.7 Grid transformations
- tree
- A connected graph with no cycles. A tree on N nodes has exactly N-1 edges, and exactly one path connects any two of its nodes.
Introduced in M5.8 Trees I: rooting, parent/order arrays, pruning and diameter
- tree diameter
- The longest path between any two nodes in a tree, found with two breadth-first searches, one to find either endpoint and a second from there to find the other.
Introduced in M5.8 Trees I: rooting, parent/order arrays, pruning and diameter
- Tree edge
- An edge in a DFS that leads to a node being visited for the first time. Tree edges form the DFS tree.
Introduced in M6.4 DFS tree properties
- true division
- Division written with
/that always produces a float, even when the numbers divide evenly.Introduced in M1.2 Integer arithmetic and operators
- two pointers
- A technique that tracks two positions into a sequence, each moving in a predictable direction, to solve a problem in one pass instead of checking every pair.
Introduced in M4.9 Two pointers and index pointers
- type
- The classification of a value, such as an integer, string, or boolean, that determines what operations it supports.
Introduced in M1.1 Values, types, variables and
print
U
- union by size
- An optimization where the smaller tree is always attached under the larger tree during union, keeping the forest shallow.
Introduced in M5.10 Disjoint Set Union (union-find)
- union-find
- Another name for disjoint set union; commonly used when describing the find and union operations.
Introduced in M5.10 Disjoint Set Union (union-find)
V
- variable
- A name that refers to a value stored while a program runs.
Introduced in M1.1 Values, types, variables and
print - verdict
- The judge's recorded result for one test case, such as accepted or wrong answer.
Introduced in M0.5 How judging works
- vertex
- A single node in a graph; the thing that edges connect.
Introduced in M4.12 Graphs I: modelling and adjacency lists
W
- walrus operator
- The
:=operator, which assigns a value to a name inside a larger expression instead of on its own line.Introduced in M1.15 The Python 3.8 language boundary