Step 6 of 6 in Mathematics
Discrete Mathematics
Sets, combinatorics, recursion, and graphs. Citation needed
The whole, before the parts
Discrete mathematics is what is left of mathematics when continuity is removed: finite and countable structures, counted and proved about rather than measured. It is the native mathematics of computation, because a computer's states are discrete, and it is the first place where proof becomes a working tool rather than a school exercise — induction in particular, which is the only way to say something about infinitely many cases in finite space. The subject divides into three jobs: proving, counting, and representing structure as a graph. Citation needed
Terminology and core concepts
-
Sets, relations, functions
The common vocabulary of the subject: a relation is a set of pairs, and a function is a relation that assigns exactly one output per input. Citation needed
- What is the cardinality of the power set of an n-element set?
- 2ⁿ Citation needed
- What makes a function injective?
- distinct inputs give distinct outputs Citation needed
- What makes a function surjective?
- every element of the codomain is hit Citation needed
- What is a bijection?
- injective and surjective at once Citation needed
- What three properties define an equivalence relation?
- reflexive, symmetric, transitive Citation needed
- What does an equivalence relation induce on its set?
- a partition into classes Citation needed
-
Proof techniques
Three methods carry nearly every proof here: direct, contradiction, and induction — and knowing which to reach for is most of the skill. Citation needed
- What does a proof by contradiction assume?
- the negation of the claim, then derives an absurdity Citation needed
- What is the contrapositive of "if P then Q"?
- if not Q then not P Citation needed
- Is the contrapositive logically equivalent to the original?
- yes Citation needed
- Which part of induction establishes the first case?
- the base case Citation needed
- What must the inductive step prove?
- if the claim holds for n, it holds for n + 1 Citation needed
- What does the inductive step prove?
- that the claim at n forces it at n+1 Citation needed
- What does strong induction assume in the step?
- the claim for all smaller cases, not just the previous one Citation needed
- What is a counterexample enough to do?
- refute a universal claim outright Citation needed
-
Counting
Two rules — multiply independent choices, add exclusive cases — generate permutations and combinations; the hard part is deciding whether order matters. Citation needed
- What does the product rule count?
- sequences of independent choices, multiplied Citation needed
- How many ways to order n distinct items?
- n! Citation needed
- What does C(n,k) count?
- unordered k-subsets of n items Citation needed
- What is the formula for C(n,k)?
- n! / (k!(n-k)!) Citation needed
- Why is C(n,k) = C(n,n-k)?
- choosing what to keep is choosing what to leave Citation needed
- When do you use permutations rather than combinations?
- when order distinguishes the outcomes Citation needed
- How many binary strings of length n are there?
- 2ⁿ Citation needed
-
Inclusion–exclusion and pigeonhole
Two counting arguments with outsized reach: one corrects for double-counting, the other proves existence without constructing anything. Citation needed
- What is the inclusion–exclusion formula for two sets?
- |A ∪ B| = |A| + |B| - |A ∩ B| Citation needed
- What does the pigeonhole principle state?
- n+1 items in n boxes force a box with two Citation needed
- What kind of conclusion does pigeonhole give?
- existence, with no construction Citation needed
- Why must 13 people share a birth month?
- 13 items, 12 boxes Citation needed
-
Recurrences
A recurrence defines a sequence by its own earlier terms, which is what a recursive algorithm's cost looks like written down. Citation needed
- What is a recurrence relation?
- a definition of each term from earlier ones Citation needed
- What recurrence defines the Fibonacci sequence?
- F(n) = F(n-1) + F(n-2) Citation needed
- What does a closed form give you that a recurrence does not?
- the term without computing all the earlier ones Citation needed
- What is the recurrence for binary search's comparison count?
- T(n) = T(n/2) + 1 Citation needed
-
Graphs
A graph is vertices plus edges, and that is enough to model roads, dependencies, friendships, and circuits — which is why graph theorems pay off far outside mathematics. Citation needed
- What is the degree of a vertex?
- the number of edges meeting it Citation needed
- What does the handshake lemma state?
- the degrees sum to twice the number of edges Citation needed
- What is a tree?
- a connected graph with no cycles Citation needed
- How many edges does a tree on n vertices have?
- n - 1 Citation needed
- When does a connected graph have an Euler circuit?
- when every vertex has even degree Citation needed
- What is a bipartite graph?
- one whose vertices split into two sides with no edge inside a side Citation needed
- What does a topological order require of a graph?
- that it be directed and acyclic Citation needed
-
Modular arithmetic
Arithmetic on remainders is a consistent system in its own right, and it is the arithmetic hashing, checksums, and public-key cryptography run on. Citation needed
- What does a ≡ b (mod n) mean?
- n divides a - b Citation needed
- What is 17 mod 5?
- 2 Citation needed
- When does a have a multiplicative inverse mod n?
- when gcd(a,n) = 1 Citation needed
- What does Fermat's little theorem state for prime p?
- ap-1 ≡ 1 (mod p) when p does not divide a Citation needed
- What does the Euclidean algorithm compute?
- the GCD, by repeated remainder Citation needed
-
Boolean algebra
The algebra of true and false, identical in structure to propositional logic and to the gates in a circuit. Citation needed
- What does De Morgan's law say about ¬(A ∧ B)?
- it equals ¬A ∨ ¬B Citation needed
- Which Boolean operation is equivalent to implication?
- ¬A ∨ B Citation needed
- How many rows does a truth table with n variables have?
- 2ⁿ Citation needed
- What is a tautology?
- a formula true under every assignment Citation needed
-
Asymptotic growth
Big-O discards constants to compare how cost grows, which is the only comparison that survives faster hardware. Citation needed
- What does O(f) bound?
- growth from above, up to a constant factor Citation needed
- Which grows faster, n log n or n²?
- n² Citation needed
- What is the complexity of binary search?
- O(log n) Citation needed
- Why are constant factors dropped?
- they do not change which function eventually dominates Citation needed
Problems that prove it
-
Prove by induction that 1 + 2 + … + n = n(n+1)/2.
Drills: the shape of an induction proof, which never varies.
Derivation steps
- Base case n = 1: left side 1, right side 1(2)/2 = 1. ✓
- Assume it holds for n = k: 1 + … + k = k(k+1)/2.
- Add k+1 to both sides: k(k+1)/2 + (k+1).
- Factor: (k+1)(k/2 + 1) = (k+1)(k+2)/2.
- That is the formula at n = k+1, so it holds for all n ≥ 1.
Citation needed
-
Prove that √2 is irrational.
Drills: contradiction, plus unique factorisation doing real work.
Derivation steps
- Suppose √2 = p/q in lowest terms.
- Then p² = 2q², so p² is even, so p is even.
- Write p = 2m: then 4m² = 2q², so q² = 2m², so q is even too.
- But p/q was in lowest terms — contradiction.
- So no such fraction exists.
Citation needed
-
How many five-card hands from a 52-card deck contain exactly two aces?
Drills: splitting a count into independent choices, order not mattering.
Derivation steps
- Choose 2 of the 4 aces: C(4,2) = 6.
- Choose 3 of the 48 non-aces: C(48,3) = 17,296.
- The choices are independent, so multiply: 6 × 17,296 = 103,776.
- Sanity check: it is a small fraction of C(52,5) = 2,598,960, about 4%. ✓
Citation needed
-
Of 100 students, 60 study French, 45 study German, and 20 study both. How many study neither?
Drills: inclusion–exclusion, then complementing.
Derivation steps
- Either language: 60 + 45 - 20 = 85.
- Neither: 100 - 85 = 15.
- The subtraction of 20 is the whole point — without it the 20 are counted twice.
Citation needed
-
Prove that in any group of six people, some three are mutual acquaintances or some three are mutual strangers.
Drills: pigeonhole on a graph — existence without construction.
Derivation steps
- Model people as vertices, acquaintance as a red edge, strangeness as blue; every pair gets one colour.
- Pick a person; they have five edges, so by pigeonhole at least three share a colour — say red, to A, B, C.
- If any pair among A, B, C is red, that pair plus the original person is a red triangle.
- If no pair among them is red, then A, B, C form a blue triangle.
- Either way a monochromatic triangle exists. (This is the Ramsey number R(3,3) = 6.)
Citation needed
-
Show that the Königsberg bridge walk is impossible, given the degrees 3, 3, 3, 5.
Drills: applying the Euler condition instead of searching for a route.
Derivation steps
- An Euler circuit needs every vertex even; an Euler path allows exactly two odd.
- Each visit to a landmass uses one edge in and one out, pairing its edges.
- Here all four vertices are odd, which is more than two.
- So no walk crosses every bridge exactly once — no case-by-case search needed.
Citation needed
-
Find the multiplicative inverse of 7 modulo 26.
Drills: the Euclidean algorithm run backwards, the step behind RSA key generation.
Derivation steps
- gcd(7,26) = 1, so an inverse exists.
- Euclid: 26 = 3(7) + 5; 7 = 1(5) + 2; 5 = 2(2) + 1.
- Back-substitute: 1 = 5 - 2(2) = 5 - 2(7 - 5) = 3(5) - 2(7).
- And 5 = 26 - 3(7), so 1 = 3(26) - 11(7).
- So -11 × 7 ≡ 1 (mod 26), and -11 ≡ 15. Check: 7 × 15 = 105 = 4(26) + 1. ✓
Citation needed
-
Solve T(n) = 2T(n/2) + n with T(1) = 1, and name the algorithm it describes.
Drills: unrolling a recurrence into a closed form.
Derivation steps
- Unroll once: T(n) = 2[2T(n/4) + n/2] + n = 4T(n/4) + 2n.
- After k levels: T(n) = 2ᵏT(n/2ᵏ) + kn.
- Recursion bottoms out at k = log₂n, where 2ᵏ = n.
- So T(n) = n + n log₂n, which is O(n log n).
- That is merge sort: each level does n work and there are log n levels.
Citation needed
Sources
- Kenneth Rosen, Discrete Mathematics and Its Applications — the standard reference for the counting and graph material.
- Lehman, Leighton and Meyer, Mathematics for Computer Science (MIT 6.042, free) — proof technique taught as a craft.
- Graham, Knuth and Patashnik, Concrete Mathematics — recurrences and sums, well past this level.
Learning path
Continue through Mathematics in order, using the concepts above to connect this topic to the next.