Study smarter with Fiveable
Get study guides, practice questions, and cheatsheets for all your subjects. Join 500,000+ students with a 96% pass rate.
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.
These structures define how we group objects and establish correspondences between them.
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:
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 .
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:
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.
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:
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.
Graphs model pairwise relationships visually and computationally. They're essential for algorithm design and network analysis.
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:
Key properties:
The Handshaking Lemma states that the sum of all vertex degrees equals , since each edge contributes to the degree of two vertices.
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:
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.
Logic provides the formal language for reasoning about truth, validity, and proof.
A proposition is a statement that's either true or false. You combine propositions using logical connectives:
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:
Predicate logic extends propositional logic with variables and quantifiers:
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 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:
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.
These techniques answer "how many?" questions. They're fundamental for algorithm analysis and probability.
Two core formulas:
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.
A recurrence relation defines each term of a sequence using previous terms. The Fibonacci sequence is a classic example: with .
Solving techniques:
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.
These structures formalize computation itself: what can be computed, how efficiently, and with what representations.
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:
Common paradigms:
Recognizing which paradigm fits a problem type is a frequent exam skill.
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.
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.
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.
Matrices and number theory provide computational tools for solving systems and securing communications.
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:
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 studies properties of integers, focusing on divisibility, primes, and modular 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 .
| 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 |
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?