1/29
Looks like no tags are added yet.
Base (termination) condition
The stopping point of a recursive function that prevents infinite recursion.
Non-recursive work f(n)
The work a function does itself in each call, excluding recursive calls, written f(n).
Divide and conquer
Divide the problem into smaller parts, delegate each part to a recursive call, then combine the results.
Recurrence relation
The general form T(n) = r·T(n/c) + O(f(n)) describing the running time of a recursive algorithm, where r is the number of recursive calls and c is the shrink factor.
Levels when dividing by c
The number of levels in a recursion tree when dividing by c: L = log_c n.
Memoisation
Storing each computed result the first time it is calculated so it can be looked up later instead of recomputed, reducing naive Fibonacci to O(n).
Fast exponentiation
A technique computing x^n by calling power(x, n/2) once and squaring the result (multiplying by x if n is odd), giving O(log n) time.
Tower of Hanoi
A recursive puzzle moving n disks between pegs using a spare peg, with minimum moves equal to 2n−1 and running time O(2n).
Mergesort
A divide-and-conquer sorting algorithm that splits an array in half, sorts each half recursively, and merges the sorted halves in O(n) time, giving O(nlogn) overall.
Quicksort
A sorting algorithm that picks a pivot, partitions elements into smaller and larger groups, and recursively sorts them; average O(nlogn), worst case O(n2).
Backtracking
A problem-solving method that builds a solution one choice at a time and undoes (backtracks) the last choice when a constraint is broken.
N Queens problem
The backtracking problem of placing N queens on an N×N board so that no two queens attack each other.
Subset Sum problem
The problem of deciding whether some subset of numbers adds up to a target value, solved by including or excluding each element, with worst case O(2n).
Proof by induction
A proof technique with a base case, an inductive hypothesis assuming correctness for smaller inputs, and an inductive step showing correctness for size n.
Decision problem
A problem with a Yes/No answer.
P (polynomial time)
The class of decision problems solvable in polynomial time by a deterministic algorithm.
NP (nondeterministic polynomial time)
The class of decision problems whose Yes answers can be verified in polynomial time.
CIRCUIT-SAT
The problem of deciding whether some input makes a Boolean circuit output 1; the standard first NP-complete problem.
Reduction
Transforming instances of problem A into instances of problem B in polynomial time, showing B is at least as hard as A.
Adjacency matrix
A graph representation using a V×V table of edges, with O(V²) space and quick edge lookup.
Adjacency list
A graph representation where each node stores a list of its neighbours, using O(V + E) space.
Depth-first search (DFS)
A graph traversal that explores as deep as possible first, using a stack or recursion.
Breadth-first search (BFS)
A graph traversal that explores level by level using a queue; it finds unweighted shortest paths.
Minimum spanning tree (MST)
A subset of edges connecting all nodes of a graph with minimum total weight and no cycles.
Prim's algorithm
An MST algorithm that repeatedly adds the cheapest edge joining the growing tree to a new node.
Kruskal's algorithm
An MST algorithm that sorts all edges by weight and adds the cheapest edge that does not create a cycle.
Dijkstra's algorithm
An algorithm finding shortest paths from one start node to all others in a graph with non-negative weights, using distances and a priority queue.
DAG (directed acyclic graph)
A directed graph with no cycles.
Halting problem
Result by Turing that no algorithm can decide, for every program and input, whether the program halts.
Babylonian method
An iterative algorithm for approximating square roots, used in lectures to discuss testing versus proving correctness.