๐งฉDiscrete Mathematics
Key Concepts in Discrete Structures
Study smarter with Fiveable
Get study guides, practice questions, and cheatsheets for all your subjects. Join 500,000+ students with a 96% pass rate.
Why This Matters
Discrete structures are the fundamental building blocks that power everything from database queries to encryption algorithms to social network analysis. When you're tested on discrete mathematics, you're being evaluated on your ability to recognize which structure models which problem, understand how operations transform these structures, and apply logical reasoning to prove properties. The concepts here (sets, relations, graphs, logic) appear repeatedly across computer science, and exam questions often ask you to connect them.
These structures form a hierarchy of increasing expressiveness. Sets give you collections, relations add connections between elements, functions constrain those connections, and graphs visualize them. Logic provides the language to reason about all of it, and combinatorics counts the possibilities. Don't just memorize definitions. Know what each structure can represent and when to use one over another.
Foundational Collections and Mappings
These structures define how we group objects and establish correspondences between them.
Sets
A set is a collection of distinct objects. It's the most primitive discrete structure. You can define a set by listing its elements or by specifying a property .
The fundamental operations you need to know:
- Union (): everything in , , or both
- Intersection (): only elements in both and
- Difference (): elements in that are not in
- Complement (): everything in the universal set that's not in
Cardinality measures the size of a set. Understanding finite vs. infinite sets matters for counting arguments, and the power set (the set of all subsets of ) has cardinality .
Relations
A relation on sets and is a set of ordered pairs where and . It generalizes the idea of "is related to."
Four key properties to check for any relation on a set:
- Reflexive: every element relates to itself ()
- Symmetric: if then
- Transitive: if and then
- Antisymmetric: if and then
An equivalence relation is one that's reflexive, symmetric, and transitive. These partition a set into disjoint equivalence classes. On exams, look for all three properties together.
A partial order is reflexive, antisymmetric, and transitive. This models "less than or equal to" style relationships.
Functions
A function is a special relation where each input maps to exactly one output. That uniqueness constraint is what makes functions predictable and useful.
Classification determines what you can do with a function:
- Injective (one-to-one): different inputs always give different outputs
- Surjective (onto): every element in the codomain is hit by some input
- Bijective (both): a perfect one-to-one correspondence, which guarantees an inverse exists
Composition means "apply first, then ." An inverse function reverses , but it only exists when is bijective.
Compare: Relations vs. Functions: both are sets of ordered pairs, but functions require unique outputs for each input. If an exam asks whether a relation is a function, check: does any input have multiple outputs? If yes, it's not a function.
Graph-Based Structures
Graphs model pairwise relationships visually and computationally. They're essential for algorithm design and network analysis.
Graphs
A graph consists of a set of vertices (nodes) connected by edges. It's the go-to structure for modeling networks, dependencies, and relationships.
Types you should know:
- Undirected: edges have no direction (friendship is mutual)
- Directed (digraph): edges have direction (following someone on social media isn't necessarily mutual)
- Weighted: edges carry numerical values (distances, costs)
- Simple: no self-loops and no multiple edges between the same pair of vertices
Key properties:
- Degree of a vertex: the number of edges connected to it. In a directed graph, you track in-degree and out-degree separately.
- Path: a sequence of vertices connected by edges
- Cycle: a path that starts and ends at the same vertex
- Connectivity: a graph is connected if there's a path between every pair of vertices
The Handshaking Lemma states that the sum of all vertex degrees equals , since each edge contributes to the degree of two vertices.
Trees
A tree is a connected graph with no cycles. Equivalently, a tree with vertices has exactly edges.
Trees have a hierarchical structure with a root node and parent-child relationships, making them natural for representing recursive structures.
Special types:
- Binary trees: each node has at most 2 children
- Binary search trees (BSTs): left child < parent < right child, enabling efficient searching
- Balanced trees: height is kept at to guarantee efficient operations
- Spanning trees: a subgraph that's a tree and includes all vertices of the original graph
Compare: Graphs vs. Trees: every tree is a graph, but trees have no cycles and exactly one path between any two nodes. For hierarchical data (file systems, org charts), trees are your structure. For general networks, use graphs.
Logical Foundations
Logic provides the formal language for reasoning about truth, validity, and proof.
Propositional Logic
A proposition is a statement that's either true or false. You combine propositions using logical connectives:
- (NOT): flips the truth value
- (AND): true only when both operands are true
- (OR): true when at least one operand is true
- (implication): is false only when is true and is false
- (biconditional): true when both sides have the same truth value
Truth tables systematically evaluate compound propositions by listing all possible input combinations. They're your main tool for proving logical equivalences.
Key equivalences to memorize:
- De Morgan's Laws: and
- Contrapositive:
- A tautology is always true; a contradiction is always false
Predicate Logic
Predicate logic extends propositional logic with variables and quantifiers:
- Universal quantifier (): "for all" or "for every"
- Existential quantifier (): "there exists" or "for some"
A predicate like expresses a property of an object. This lets you write statements like "for all integers , if is even, then is even."
Negating quantified statements is a common exam skill:
When negating, you flip the quantifier and negate the predicate. For nested quantifiers, apply this rule from left to right.
Boolean Algebra
Boolean algebra is a two-valued system (true/false, 1/0) with operations AND, OR, and NOT. It provides the mathematical foundation of digital circuits.
Key algebraic laws for simplifying expressions:
- Associativity, commutativity, distributivity (AND distributes over OR and OR distributes over AND)
- Absorption:
- Identity: ,
- Complement: ,
These laws apply directly in circuit design, programming conditionals, and database queries.
Compare: Propositional vs. Predicate Logic: propositional logic handles fixed statements ("it is raining"); predicate logic adds variables and quantifiers for statements about all or some objects ("for all days , if it rains on , the ground is wet"). Exam questions often require translating English sentences into predicate logic notation.
Counting and Recurrence
These techniques answer "how many?" questions. They're fundamental for algorithm analysis and probability.
Combinatorics
Two core formulas:
- Permutations (order matters):
- Combinations (order doesn't matter):
The inclusion-exclusion principle counts the size of unions by correcting for overcounting:
This extends to more sets. For three sets:
The pigeonhole principle is deceptively powerful: if you place items into containers and , at least one container holds more than one item. Many proof problems rely on this.
Recurrence Relations
A recurrence relation defines each term of a sequence using previous terms. The Fibonacci sequence is a classic example: with .
Solving techniques:
- Iteration (unrolling): substitute repeatedly until you spot a pattern, then prove it
- Characteristic equation: for linear recurrences like , solve to find the closed form
- Generating functions: a more advanced technique that encodes the sequence as coefficients of a power series
In algorithm analysis, the Master Theorem solves recurrences of the form , which arise from divide-and-conquer algorithms.
Compare: Permutations vs. Combinations: both count selections from a set, but order matters for permutations () and doesn't for combinations. Ask yourself: "Does rearranging the selection change the outcome?" If yes, use permutations. If no, use combinations.
Computational Models and Languages
These structures formalize computation itself: what can be computed, how efficiently, and with what representations.
Algorithms
An algorithm is a step-by-step procedure for solving a problem. The two key concerns are correctness (does it produce the right answer?) and efficiency (how fast and with how much memory?).
Complexity analysis uses Big-O notation to describe growth rates:
- Time complexity: how the number of operations grows with input size
- Space complexity: how memory usage grows with input size
Common paradigms:
- Divide and conquer: split the problem, solve subproblems, combine results (e.g., merge sort)
- Dynamic programming: solve overlapping subproblems once and store results (e.g., Fibonacci with memoization)
- Greedy: make the locally optimal choice at each step (e.g., Dijkstra's shortest path)
Recognizing which paradigm fits a problem type is a frequent exam skill.
Finite State Machines
A finite state machine (FSM) is a computational model with a finite number of states, transitions triggered by inputs, and designated accepting states. It models systems with limited memory.
- Deterministic FSMs (DFAs): exactly one transition per state-input pair
- Nondeterministic FSMs (NFAs): multiple possible transitions for a given state-input pair
Every NFA can be converted to an equivalent DFA (though the DFA may have exponentially more states). FSMs are used in lexical analysis, protocol design, and pattern matching.
Formal Languages
A formal language is a set of strings over some alphabet, defined by grammatical rules. It formalizes what "valid syntax" means.
The Chomsky hierarchy classifies languages by complexity:
| Language Type | Recognized By |
|---|---|
| Regular | Finite state machines |
| Context-free | Pushdown automata |
| Context-sensitive | Linear-bounded automata |
| Recursively enumerable | Turing machines |
Each level is strictly more powerful than the one above it. Regular languages are the simplest; recursively enumerable languages are the most general.
Compare: FSMs vs. Formal Languages: FSMs are the machines that recognize languages; formal languages are the sets of strings being recognized. An FSM accepts exactly those strings belonging to its corresponding regular language.
Algebraic Structures
Matrices and number theory provide computational tools for solving systems and securing communications.
Matrices
A matrix is a rectangular array of values arranged in rows and columns. Matrices represent linear transformations and systems of equations.
Key operations and facts:
- Addition: element-wise, requires same dimensions
- Multiplication: is defined when the number of columns in equals the number of rows in . Matrix multiplication is not commutative ( in general).
- Determinant: a scalar value that tells you whether a matrix is invertible. exists if and only if .
- Identity matrix : the matrix equivalent of multiplying by 1
For discrete math specifically, adjacency matrices represent graphs. Entry equals 1 if there's an edge from vertex to vertex , and 0 otherwise. A powerful result: the entry in gives the number of paths of length from vertex to vertex .
Number Theory
Number theory studies properties of integers, focusing on divisibility, primes, and modular arithmetic.
- Fundamental Theorem of Arithmetic: every integer greater than 1 has a unique prime factorization. This is the foundation for many proofs about integers.
- GCD and LCM: the greatest common divisor and least common multiple. The Euclidean algorithm efficiently computes the GCD through repeated division.
- Modular arithmetic: means divides . This is essential for cryptography (RSA relies on modular exponentiation), hashing, and computer arithmetic.
Compare: Matrices vs. Graphs: an adjacency matrix is a graph representation. Entry indicates an edge from vertex to vertex . Matrix operations then have graph interpretations: counts paths of length .
Quick Reference Table
| Concept | Best Examples |
|---|---|
| Collection/Grouping | Sets, Multisets, Power sets |
| Relationships | Relations, Functions, Equivalence classes |
| Network Modeling | Graphs, Trees, Directed acyclic graphs |
| Logical Reasoning | Propositional logic, Predicate logic, Boolean algebra |
| Counting | Combinatorics, Inclusion-exclusion, Binomial coefficients |
| Sequence Analysis | Recurrence relations, Closed-form solutions |
| Computation Models | Algorithms, FSMs, Formal languages |
| Algebraic Tools | Matrices, Number theory, Modular arithmetic |
Self-Check Questions
-
Both relations and functions are sets of ordered pairs. What property distinguishes a function from a general relation, and how would you verify this property given a relation?
-
Compare graphs and trees: what structural constraint makes a tree a special case of a graph, and what property does this guarantee about paths between vertices?
-
If you need to count the number of ways to select a committee of 5 from 12 people, would you use permutations or combinations? What if the committee has a chair, vice-chair, and three regular members?
-
Explain how propositional logic and predicate logic differ in expressiveness. Give an example of a statement that requires predicate logic to express formally.
-
A recurrence relation defines with . What type of algorithm typically produces this recurrence, and what is its time complexity in Big-O notation?