MGU Mathematics Series — Discrete Mathematics
Part V: Discrete Models, Computation, and Capstone Structures
Modeling · Synthesis · Capstone · Applications
Chapter 14 of 14
MGU Mathematics Series  ·  Discrete Mathematics  ·  Library Textbook Edition

Chapter 14:
Discrete Mathematics
Capstone and Applications

Logic, sets, proof, induction, counting, graphs, recursion, algorithms, modular arithmetic, and Boolean algebra — brought together into a single toolkit for modeling real systems

■ Math Level: Discrete Mathematics ■

■ 15 Sections  •  Part V of 5 ■

Follows Chapter 13: Boolean Algebra, Circuits, and Digital Logic  ·  Completes the Discrete Mathematics Library Textbook Edition

Purpose and Overview

This chapter closes the textbook. Its purpose is not to introduce entirely new material but to show how the tools of discrete mathematics work together as a unified system of reasoning. In the chapters that came before, you learned to think logically, write proofs, count structured collections, navigate graphs and networks, design algorithms, work with modular arithmetic, and reason about digital circuits. Each of those chapters gave you one part of a larger toolkit.

This capstone chapter teaches you how to use that toolkit on real problems — problems that do not arrive pre-labeled with the method you should use. You will learn to read a situation carefully, identify the discrete structure that fits it, select the right tools, reason through a solution, and explain your conclusion clearly.

Discrete mathematics is the mathematics of separate objects, finite choices, logical structure, countable systems, networks, and step-by-step procedures. By the end of this chapter, you should feel that the subject is not a collection of unrelated topics but a coherent language for reasoning about structured systems — a language spoken by computer scientists, cryptographers, network engineers, database designers, logicians, and mathematicians alike.

Opening Question

A university wants to build a new registration system. Students must be assigned to course sections without conflicts. Some courses have prerequisites that must be completed first. Each section has a limited number of seats. Some combinations of courses are restricted for students in certain majors. The system must check whether a given schedule is valid, count how many valid schedules exist, and find the most efficient way to assign rooms.

Where do you begin? What mathematical tools apply? This chapter will show you that each part of this problem calls for a different piece of discrete mathematics — and that selecting the right tool is itself a mathematical skill.

Why This Chapter Matters

Every major chapter in this book developed a different layer of discrete reasoning. But real problems rarely announce themselves by chapter number. A network security analyst looking at access logs does not think "this is a graph theory problem." A database administrator writing a query does not think "this is a set theory problem." A programmer analyzing an algorithm does not think "I will now apply Big-O notation." These people think about the situation first, and the mathematics follows from understanding the structure of the problem.

This chapter teaches that transition: from knowing the tools to using the tools. It also prepares you for what comes next — courses in algorithms, data structures, programming, cybersecurity, cryptography, database design, artificial intelligence, and higher mathematics — where discrete reasoning will be the foundation you return to again and again.

15Sections
7Objectives
11Key Terms
10Worked Examples

Learning Objectives

  1. 1Describe the discrete modeling process and apply it to unfamiliar problems.
  2. 2Identify which discrete structure — sets, logic, counting, graphs, recursion, modular arithmetic, Boolean algebra, or algorithms — best fits a given situation.
  3. 3Apply multiple discrete tools together to analyze a single problem.
  4. 4Write clear explanations of discrete reasoning, including definitions, claims, justifications, and conclusions.
  5. 5Model realistic systems from computer science, networks, scheduling, cryptography, databases, digital logic, and cybersecurity using discrete mathematics.
  6. 6Recognize common mistakes in discrete modeling and avoid them.
  7. 7Describe how discrete mathematics connects to advanced study in computer science, mathematics, and related fields.

Key Terms from Earlier Chapters

Before reading this chapter, you should be comfortable with the following terms from earlier chapters. Each term is listed with the chapter where it was introduced.

discrete structure
A mathematical object made of separate, countable parts, such as a set, graph, sequence, relation, or logical system. (Ch. 1)
logical statement
A sentence that is either true or false. (Ch. 2)
set
A collection of distinct objects described precisely using notation. (Ch. 3)
relation
A set of ordered pairs describing how objects are connected. (Ch. 3)
proof
A sequence of justified steps that establishes why a claim must be true. (Ch. 4)
mathematical induction
A proof method for statements indexed by whole numbers, using a base case and an inductive step. (Ch. 5)
recursive definition
A definition that describes a structure in terms of simpler versions of itself. (Ch. 5)
modular arithmetic
Arithmetic on integers where numbers wrap around after reaching a fixed modulus. (Ch. 6)
counting principle
A rule for determining the number of outcomes in a structured situation. (Ch. 7)
permutation
An ordered arrangement of objects. (Ch. 8)
combination
An unordered selection of objects. (Ch. 8)
graph
A structure consisting of vertices and edges representing connections. (Ch. 10)
algorithm
A precise, finite, step-by-step procedure for solving a problem. (Ch. 12)
Big-O notation
A way of describing the growth rate of an algorithm's resource use as input size grows. (Ch. 12)
Boolean algebra
An algebraic system with two values, used to model logic and digital circuits. (Ch. 13)

Sections at a Glance

Sections 14.1 – 14.2
The Modeling Process and Choosing a Structure
Read · Represent · Reason · Solve · Check · Explain · Selecting the Right Tool

The Discrete Modeling Process

When a mathematician or computer scientist encounters a real problem, the first step is not computation. The first step is understanding the structure of the situation. What objects are involved? How are they connected? What rules apply? What are you trying to find, count, verify, or optimize?

This process of translating a real situation into a mathematical structure is called modeling. A discrete model is a mathematical representation of a system using the language of discrete mathematics — sets, relations, graphs, logic, algorithms, or some combination of these.

The modeling process can be organized into six stages, which echo the problem-solving method used throughout this book.

The Six-Stage Modeling Process

Read — Read the situation carefully. Identify what is given and what is being asked. Do not rush to a formula or a method. Many modeling errors happen because a student misreads the problem — they count when they should prove, or they use a graph when they should use a relation.

Represent — Choose a discrete structure that captures the key features of the situation. You are looking for the representation that makes the important relationships visible. A schedule conflict is easier to see in a graph than in a table. A password rule is easier to analyze using counting principles than in words.

Reason — Apply the definitions, theorems, proof methods, counting rules, graph properties, algorithm logic, or Boolean laws that are relevant to the structure you chose. Stay close to definitions. Discrete reasoning depends on precise meanings.

Solve — Carry out the reasoning step by step. Show your work. Do not skip steps when the reasoning is the point.

Check — Verify that your answer satisfies the conditions of the original problem. Does the count make sense? Does the proof handle every case? Does the graph representation actually encode what you intended?

Explain — Write a clear explanation of what you found and why it is correct. Discrete mathematics is not just about getting a number or a yes-or-no answer. It is about being able to justify the answer to someone who has not seen your work.

Not a Formula — a Discipline

This process is not a rigid sequence to follow mechanically. It is a habit of mind. With practice, it becomes natural: you will find yourself reading carefully, picturing a structure, and reasoning from definitions almost automatically.

Example 14.1.1
Applying the modeling process
  • ProblemA city has five bus stations: Downtown, Airport, University, Mall, and Hospital. There are direct bus routes between Downtown and Airport, Downtown and University, Airport and Mall, University and Hospital, and Mall and Hospital. Can a traveler visit all five stations using a route that starts and ends at the same station and uses each direct route exactly once?
  • ThinkThis problem is about routes, stations, and connections. The structure is a network of places connected by routes. This suggests a graph model. The specific question — can we travel each route exactly once in a circuit that returns to its start? — is the definition of an Euler circuit from Chapter 11.
  • Represent Vertices: D (Downtown), A (Airport), U (University), M (Mall), H (Hospital) Edges: D–A, D–U, A–M, U–H, M–H Compute the degree of each vertex by counting how many edges connect to it: deg(D) = 2 (D–A, D–U) deg(A) = 2 (D–A, A–M) deg(U) = 2 (D–U, U–H) deg(M) = 2 (A–M, M–H) deg(H) = 2 (U–H, M–H)
  • ReasonBy Euler's theorem (Chapter 11), an Euler circuit exists in a connected graph if and only if every vertex has even degree. Every vertex here has degree 2, which is even. The graph is also connected — every station can be reached from every other station through some sequence of routes. Therefore an Euler circuit exists.
  • SolveOne such circuit: D → A → M → H → U → D Each route is used exactly once and the circuit returns to the starting station.
  • CheckRoutes used: D–A, A–M, M–H, H–U, U–D. That is five routes, matching the five edges of the graph. Every route is used exactly once, and the circuit returns to D. ✓
Answer: Yes. A traveler can visit all five stations using each direct route exactly once in a circuit. One such route is Downtown → Airport → Mall → Hospital → University → Downtown. This is guaranteed by Euler's theorem, since every station has even degree and the network is connected.
Diagram Instruction

Draw five vertices in a circular arrangement labeled D (Downtown), A (Airport), M (Mall), H (Hospital), and U (University), in that order around the circle. Connect each vertex to its neighbor going around the circle: D–A, A–M, M–H, H–U, and U–D. The result is a single cycle through all five vertices — this is the Euler circuit found in Example 14.1.1. Label the degree "2" beside each vertex to show that every vertex has even degree.

Practice 14.1Applying the Modeling Process
  1. A small office network has four computers: P, Q, R, S, connected by cables P–Q, Q–R, R–S, and S–P. Using the modeling process, determine whether a technician can trace every cable exactly once and return to the starting computer. Show each of the six stages.
  2. Explain in your own words why the "Represent" stage is often the most important stage of the modeling process. Give an example of a problem where choosing the wrong representation would make the problem much harder.
  3. A delivery company has six warehouses connected by direct roads forming a single cycle (each warehouse connects to exactly two others, forming one large loop). Without drawing the diagram, determine whether an Euler circuit exists, and justify your answer using the degree of each vertex.

Choosing a Discrete Structure

One of the most important skills in applied discrete mathematics is knowing which structure fits a given situation. This section surveys the major discrete structures from the course and identifies the kinds of situations each one is designed to handle.

Sets and Relations

Use sets when you need to describe and reason about collections of objects with precise membership rules: classifying objects by category or property, finding what two groups have in common or what differs between them, describing the domain or range of a function, or working with databases, filters, and search conditions.

Use relations when objects are paired by some rule or connection: describing which objects relate to which others, studying properties like reflexivity, symmetry, or transitivity, or modeling dependencies, comparisons, orderings, or associations.

Logic

Use logic when you need to evaluate, combine, or transform statements based on their truth values: analyzing whether an argument is valid, simplifying a compound condition in a program or system, stating a claim precisely and finding its contrapositive or negation, working with database queries or decision conditions, or building and analyzing a circuit.

Proof

Use proof methods when you need to justify why a claim is true for all cases or show that a general pattern holds: proving a property holds for every integer, graph, set, or element of some class; showing a proposed algorithm is correct; establishing an identity or inequality algebraically; or disproving a claim by finding a counterexample.

Mathematical Induction and Recursion

Use induction when you need to prove a statement indexed by whole numbers — a statement of the form "for every n greater than or equal to some starting value, P(n) is true." Use recursion when you need to define a structure or compute a quantity in terms of simpler versions of itself.

Modular Arithmetic

Use modular arithmetic when your situation involves cyclic behavior, remainders, or arithmetic that wraps around: clock arithmetic, calendar calculations, or cyclic schedules; verifying checksums, hash values, or error-detection codes; studying cryptographic systems; or determining whether two numbers behave identically under a particular divisor.

Counting Principles

Use counting when you need to determine the number of outcomes in a structured situation without listing them all: finding how many arrangements, selections, or sequences are possible; computing discrete probability; verifying that a space is large enough or small enough to be useful; or analyzing the number of possible inputs to an algorithm.

Graph Theory

Use graphs when your situation involves objects connected by relationships: modeling networks of any kind — roads, computers, social connections, dependencies; asking about paths, circuits, connectivity, or reachability; scheduling, coloring, or assigning resources to avoid conflicts; or representing the states of a system and the transitions between them.

Algorithms

Use algorithmic thinking when you need to specify a step-by-step process that solves a problem for any valid input: describing how a computation should proceed, not just what the answer should be; comparing the efficiency of two approaches to the same problem; or analyzing the worst case, best case, or average case behavior of a procedure.

Boolean Algebra

Use Boolean algebra when you need to model, simplify, or analyze systems built from two-valued logic: designing or analyzing digital circuits; simplifying compound logical conditions in software or hardware; or working with binary values, truth conditions, or gate networks.

Quick Reference Table

SituationStructure to Use
Collections, categories, filtersSets
Paired objects, dependencies, orderingsRelations
Statements, conditions, argumentsLogic
Justifying a general claimProof
Claim true for all n ≥ base caseInduction
Object defined by smaller versions of itselfRecursion
Cyclic arithmetic, remainders, clocksModular arithmetic
How many arrangements or selections?Counting (permutations, combinations)
Networks, connections, pathsGraph theory
Step-by-step procedure, efficiencyAlgorithms
Two-valued logic, circuits, binaryBoolean algebra
More Than One Tool

In practice, a single problem may require more than one structure. The art of discrete modeling is choosing the right combination — and recognizing when a problem has multiple parts, each calling for a different tool.

Practice 14.2Identifying the Right Structure
  1. A teacher wants to know how many ways 4 students can be chosen from a class of 20 to form a committee. Which structure applies, and why?
  2. A network administrator needs to know whether every computer in a network can communicate with every other computer, possibly through intermediate computers. Which structure applies, and why?
  3. A programmer wants to prove that a sorting algorithm always produces a sorted list, no matter the input. Which structure (or structures) apply, and why?
  4. A security system grants access if a user enters the correct password AND their device is registered. Which structure applies, and why?
  5. A cryptographic system needs to determine the remainder when a very large number is divided by a smaller one. Which structure applies, and why?
  6. A data structure is defined as either empty, or a value attached to a smaller version of the same structure. Which structure applies, and why?
Sections 14.3 – 14.6
Applying the Tools: Sets, Logic, Counting, and Graphs
Sets and Relations · Logic · Counting · Graph Theory

Modeling with Sets and Relations

Sets and relations are among the most fundamental tools of discrete mathematics because they give precise meaning to words like "collection," "membership," "category," "connection," and "order."

Sets in Database Modeling

A relational database stores information in tables. Each table represents a set of records. A query uses set operations to extract, combine, or filter information.

Database OperationSet-Theoretic Meaning
SELECTSelecting a subset: {x ∈ S | P(x)}, where P(x) is the condition
JOINA Cartesian product of two tables, filtered by a condition
UNIONThe set union A ∪ B of two query results
INTERSECTIONThe set intersection A ∩ B
DIFFERENCERecords in one table but not another: A \ B
Not Just an Analogy

These correspondences are not loose analogies. The mathematics of set operations directly underlies the design of database query languages such as SQL. When you write a query, you are writing a set-theoretic expression.

Relations in Scheduling

Suppose a university must schedule final exams. Two courses conflict if at least one student is enrolled in both — they cannot be scheduled at the same time. Define a relation C on the set of courses where (X, Y) ∈ C means course X and course Y have at least one student in common. This conflict relation is:

Properties of the Conflict Relation

Symmetric — If X conflicts with Y, then Y conflicts with X.

Irreflexive — A course does not conflict with itself.

Not necessarily transitive — X conflicting with Y and Y conflicting with Z does not mean X conflicts with Z.

Connecting Two Structures

The conflict relation can be represented as a graph (Chapter 10), where courses are vertices and conflicts are edges. The exam scheduling problem then becomes a graph coloring problem: assign a time slot (color) to each course so that no two conflicting courses share a time slot. The minimum number of time slots needed equals the chromatic number of the graph. This is an excellent example of how two discrete structures — relations and graphs — work together to model a real problem.

Example 14.3.1
Modeling with a relation
  • ProblemLet A = {1, 2, 3, 4, 6, 12} be the set of positive divisors of 12. Define the relation D on A where (a, b) ∈ D means "a divides b." List several elements of D and determine whether D is reflexive, antisymmetric, and transitive.
  • ThinkIdentify pairs (a, b) where a | b, then check the three relation properties using their definitions from Chapter 3.
  • Solve Recall that a | b means b = ka for some integer k. Some elements of D: (1,1), (1,2), (1,3), (1,4), (1,6), (1,12), (2,2), (2,4), (2,6), (2,12), (3,3), (3,6), (3,12), (4,4), (4,12), (6,6), (6,12), (12,12) Reflexive: Is (a, a) ∈ D for every a ∈ A? Yes, because every integer divides itself (a = 1 · a). ✓

    Antisymmetric: If (a, b) ∈ D and (b, a) ∈ D, does that force a = b? If a | b and b | a, and both are positive integers, then a = b. Yes, D is antisymmetric. ✓

    Transitive: If (a, b) ∈ D and (b, c) ∈ D, is (a, c) ∈ D? If a | b and b | c, then b = ka and c = lb, so c = lka, meaning a | c. Yes, D is transitive. ✓
  • CheckA relation that is reflexive, antisymmetric, and transitive is called a partial order. The divisibility relation on a set of positive integers is a standard example of a partial order.
Answer: The relation "a divides b" on the divisors of 12 is a partial order — it is reflexive, antisymmetric, and transitive.
Practice 14.3Sets and Relations
  1. A music streaming service stores songs in a table with columns Title, Artist, Genre, and Year. Describe, using set notation, the query: "all songs by Artist X released after 2015."
  2. Let B = {2, 4, 8, 16, 32}. Define the relation R on B where (a, b) ∈ R means "a ≤ b." Is R reflexive? Antisymmetric? Transitive? What kind of relation is R?
  3. A school has five clubs. Two clubs "conflict" if they meet on the same day and share at least one member who attends both. Explain how this conflict relation could be modeled as a graph, and what question about that graph would tell the school the minimum number of meeting days needed.
  4. For two database tables Students and Enrollments, describe in words what a JOIN of the two tables on a shared "Student ID" column represents, using the language of Cartesian products and set conditions.

Modeling with Logic

Logic is the language of conditions, decisions, and valid inference. In any system that must make decisions — whether a program, a circuit, a database query, or a security policy — the underlying structure is logical.

Logic in Access Control

A cybersecurity access control system grants a user access to a file if a compound condition is satisfied. For example:

"Access is granted if the user is authenticated AND (is an administrator OR the file is public)."

Translating the Condition

Let p = "the user is authenticated," q = "the user is an administrator," and r = "the file is public." The access condition is:

\( p \land (q \lor r) \)

A system designer can use a truth table to verify exactly when access is granted, identify unexpected cases, or simplify the condition using logical equivalences. For instance, the distributive law from Chapter 2 gives:

\[ p \land (q \lor r) \equiv (p \land q) \lor (p \land r) \]

This allows the condition to be rewritten in a form that may be easier to implement in a specific programming language or circuit design.

Logic in Proving Algorithm Correctness

Algorithms are often verified using logical conditions called preconditions and postconditions. A precondition states what must be true before the algorithm runs. A postcondition states what should be true after it finishes. Proving correctness means showing: if the precondition holds and the algorithm runs, then the postcondition holds. This is a conditional statement — exactly the kind of structure studied in Chapter 2.

Example 14.4.1
Simplifying a security condition
  • ProblemA network security rule states: "A packet is blocked if it does NOT originate from the internal network AND is NOT marked as trusted." Translate this into a logical expression and find its equivalent using De Morgan's Laws.
  • ThinkTranslate the English rule into logical notation, then apply De Morgan's Laws to find an equivalent form.
  • Solve Let p = "the packet originates from the internal network" and q = "the packet is marked as trusted."

    The rule says: block if (NOT p) AND (NOT q). ¬p ∧ ¬q By De Morgan's Law, ¬(A ∨ B) ≡ ¬A ∧ ¬B. Applying it in reverse: ¬p ∧ ¬q ≡ ¬(p ∨ q)
  • CheckDe Morgan's Law states \( \neg(A \lor B) \equiv \neg A \land \neg B \). Applying it in reverse gives \( \neg p \land \neg q \equiv \neg(p \lor q) \). ✓
Answer: The blocking condition ¬p ∧ ¬q is logically equivalent to ¬(p ∨ q), which reads: "Block a packet if it is NOT the case that the packet is from the internal network OR marked as trusted." Both forms express the same rule; the second may be easier to code as a single negated OR-condition.
Practice 14.4Modeling with Logic
  1. A streaming service allows playback if the user has an active subscription AND (the content is in their region OR the user has a travel pass). Write this condition using p, q, and r, and construct its truth table.
  2. Write the negation of the condition from Problem 1 using De Morgan's Laws, and explain in plain English what it means for playback to be denied.
  3. An algorithm's precondition is "the input list is non-empty," and its postcondition is "the returned value is the maximum element of the list." Write a sentence describing what it would mean to prove this algorithm correct, using the language of conditional statements.
  4. A login system locks an account if the user enters an incorrect password AND has already failed 2 or more times. Write this as a logical expression, then write its negation and interpret it.

Modeling with Counting

Counting is used whenever you need to determine the number of possibilities in a structured system. This matters in cryptography (how large is a keyspace?), scheduling (how many valid timetables exist?), probability (how likely is an event?), and algorithm analysis (how many inputs need to be checked?).

Password Security

A password system requires passwords of exactly 8 characters, where each character is a lowercase letter (26 options) or a digit (10 options), giving 36 choices per character. The number of possible passwords is:

\[ 36^8 = 2{,}821{,}109{,}907{,}456 \]

That is approximately 2.8 trillion passwords. If an attacker can try one million passwords per second, exhaustive search takes over 2.8 million seconds — roughly 32 days.

If the system also requires at least one digit, the count changes. Use complementary counting: total passwords minus passwords with no digits at all.

Complementary Counting for Passwords

Total passwords: \( 36^8 \)

Passwords with no digits (all letters): \( 26^8 \)

Passwords with at least one digit: \( 36^8 - 26^8 \)

Counting gives a direct way to evaluate whether a system is secure enough — not as a vague assertion, but as a precise mathematical statement.

Scheduling Problems

Suppose a conference has 5 speakers and 3 time slots. Each speaker appears in exactly one slot, and each slot holds exactly one speaker. Only 3 of the 5 speakers will present. The number of ways to schedule the conference:

Choose which 3 of the 5 speakers present: C(5,3) = 10 ways Arrange those 3 speakers in 3 time slots: 3! = 6 ways Total: 10 × 6 = 60 schedules
Example 14.5.1
Counting valid assignments
  • ProblemA team of 10 students will be divided into two groups: a group of 4 and a group of 6. Within the group of 4, one student will be designated as team leader. How many ways can this be done?
  • ThinkThe process has two stages: form the groups, then designate a leader within the group of 4. Use the product rule.
  • Solve Step 1: Choose 4 students from 10 for the first group. C(10,4) = 10! / (4! · 6!) = 210 The remaining 6 students automatically form the second group.

    Step 2: From the 4 students in the first group, choose 1 as team leader. 4 choices
    Step 3: By the product rule: 210 × 4 = 840
  • CheckWe made two independent choices — which 4 students, then which of those 4 leads. The product rule applies. ✓
Answer: There are 840 ways to form the two groups and designate a leader.
Practice 14.5Modeling with Counting
  1. A PIN code consists of 4 digits, each from 0–9, with repetition allowed. How many PINs are possible? How many contain no repeated digits?
  2. A security badge requires a code of 6 characters: the first 2 characters are letters (26 options each) and the last 4 are digits (10 options each), with repetition allowed in each part. How many codes are possible?
  3. A committee of 3 must be chosen from a group of 12 people, and then a chairperson must be chosen from those 3. How many outcomes are possible? Use the product rule and show each stage.
  4. A Wi-Fi password must be at least 8 characters and use only the 26 lowercase letters, but must contain at least one vowel (a, e, i, o, u). Using complementary counting, write an expression for the number of valid 8-character passwords.

Modeling with Graphs

Graph theory is the natural language for any situation where objects are connected by relationships. Graphs appear in network design, routing, scheduling, social networks, dependency analysis, and map coloring.

Representing Dependencies

In software development, a project has tasks that must be completed in a specific order. Task A must be done before Task C. Task B must be done before Task C and Task D. Task D must be done before Task E. This ordering defines a directed acyclic graph (a DAG), where each directed edge (X, Y) means "X must be done before Y." Finding a valid order for completing all tasks is called topological sorting, a well-known graph algorithm.

Diagram Instruction

Draw five vertices labeled A, B, C, D, and E. Draw directed edges (arrows): A → C, B → C, B → D, D → E. Notice that C has two incoming arrows (from A and B), and D has one incoming arrow (from B) and one outgoing arrow (to E). A valid topological order must place A and B before C, B before D, and D before E. One valid order is A, B, C, D, E or B, A, C, D, E.

Network Routing

A computer network can be modeled as a weighted graph, where vertices represent routers or computers, edges represent direct connections, and edge weights represent latency, bandwidth cost, or distance.

Finding the fastest route between two nodes is the shortest path problem (solved by Dijkstra's algorithm, Chapter 11). Finding the cheapest way to connect all nodes is the minimum spanning tree problem (solved by Kruskal's or Prim's algorithm, Chapter 11).

Example 14.6.1
Modeling a conflict graph
  • ProblemFive tasks must be scheduled: A, B, C, D, E. Tasks conflict (cannot run simultaneously) if they share a resource: A conflicts with B, A conflicts with C, B conflicts with D, C conflicts with D, and D conflicts with E. What is the minimum number of time slots needed?
  • ThinkModel the conflicts as a graph. The minimum number of time slots needed equals the chromatic number of the graph — the minimum number of colors needed to color the vertices so no two adjacent vertices share a color.
  • RepresentVertices: A, B, C, D, E. Edges: A–B, A–C, B–D, C–D, D–E.
  • Reason Look for a triangle (three mutually conflicting tasks), which would force at least 3 colors.

    Does A, B, D form a triangle? A–B ✓, B–D ✓, A–D? No edge A–D. Not a triangle.
    Does A, C, D form a triangle? A–C ✓, C–D ✓, A–D? No. Not a triangle.

    Since no triangle exists, the graph might be 2-colorable. Try a 2-coloring directly.
  • Solve Color A with slot 1. B and C (both adjacent to A) get slot 2. D (adjacent to both B and C, which are slot 2) gets slot 1. E (adjacent to D, slot 1) gets slot 2. A = 1, B = 2, C = 2, D = 1, E = 2
  • CheckCheck every edge: A–B (1,2) ✓, A–C (1,2) ✓, B–D (2,1) ✓, C–D (2,1) ✓, D–E (1,2) ✓. No edge connects two vertices of the same color.
Answer: Two time slots are sufficient. Assign A and D to slot 1, and B, C, and E to slot 2. This is the minimum possible, since A and B conflict directly, requiring at least two slots.
Diagram Instruction

Draw five vertices: place A at the top, B and C below it on either side, D below B and C, and E below D. Draw edges A–B, A–C, B–D, C–D, D–E. Shade A and D in one color (slot 1) and shade B, C, and E in a second color (slot 2). No edge should connect two vertices of the same shade.

Practice 14.6Modeling with Graphs
  1. A project has tasks A, B, C, D with dependencies: A before B, A before C, B before D, C before D. Draw this as a DAG and find a valid topological order.
  2. A network has four routers W, X, Y, Z with weighted connections: W–X (2ms), W–Y (5ms), X–Z (3ms), Y–Z (1ms), X–Y (4ms). Find the shortest path from W to Z, and explain your reasoning.
  3. Six exams must be scheduled: P, Q, R, S, T, U. Conflicts (students taking both): P–Q, P–R, Q–S, R–T, S–U, T–U. Model this as a graph. Is the graph 2-colorable? If not, find the minimum number of time slots and a valid assignment.
  4. Explain, in two or three sentences, why a problem about "the cheapest way to connect all offices with cable" is a minimum spanning tree problem rather than a shortest path problem. What is the difference in what each problem is asking?
Sections 14.7 – 14.10
Applying the Tools: Recursion, Algorithms, Modular Arithmetic, and Boolean Algebra
Recursion · Algorithms · Modular Arithmetic · Boolean Algebra

Modeling with Recursion

Recursion appears whenever a structure is built by repeating a simpler version of itself. Recursive definitions are used to describe data structures (trees, lists), to specify algorithms, and to count combinatorial objects.

Recursive Structures in Computing

The structure of a file system is recursive: a folder contains files and other folders, each of which contains files and other folders, and so on. The base case is a folder containing only files (no subfolders). The recursive case is a folder that contains at least one subfolder.

To compute the total number of files in a folder, you can write a recursive algorithm:

FileCount(folder): total = number of files directly in folder for each subfolder in folder: total = total + FileCount(subfolder) return total

This algorithm follows the recursive structure of the data. Its correctness can be proved by structural induction — a form of induction adapted to recursive structures, introduced in Chapter 5.

Recurrence Relations in Algorithm Analysis

Many algorithms are naturally analyzed using recurrence relations. The binary search algorithm (Chapter 12) works on an input of size n by checking the middle element, then recursively searching a half-sized input. Its runtime T(n) satisfies:

\[ T(n) = T\!\left(\frac{n}{2}\right) + 1, \qquad T(1) = 1 \]

Solving this recurrence (by unrolling, or by the methods of Chapter 9) gives \( T(n) = O(\log n) \) — confirming that binary search is dramatically faster than linear search for large inputs.

Example 14.7.1
Building a recursive model
  • ProblemA staircase has n steps. You can climb either 1 step or 2 steps at a time. Let f(n) be the number of distinct ways to climb n steps. Find a recursive definition for f(n) and compute f(5).
  • ThinkTo reach step n, your last move was either from step n − 1 (a single step) or from step n − 2 (a double step). So the number of ways to reach step n equals the number of ways to reach step n − 1 plus the number of ways to reach step n − 2.
  • Solve Base cases: f(1) = 1 (one way: a single step of size 1) f(2) = 2 (two ways: 1+1, or 2) Recursive case for n ≥ 3: f(n) = f(n−1) + f(n−2) This is the Fibonacci recurrence. Computing: f(3) = f(2) + f(1) = 2 + 1 = 3 f(4) = f(3) + f(2) = 3 + 2 = 5 f(5) = f(4) + f(3) = 5 + 3 = 8
  • CheckFor f(3): the ways are {1,1,1}, {1,2}, {2,1}. That is 3 ways, matching the computed value. ✓
Answer: f(n) = f(n−1) + f(n−2), with f(1) = 1 and f(2) = 2. For n = 5, there are f(5) = 8 distinct ways to climb the staircase.
Practice 14.7Modeling with Recursion
  1. A sequence is defined recursively by a(1) = 2 and a(n) = 3 · a(n−1) for n ≥ 2. Compute a(1) through a(5), and write a closed-form (non-recursive) formula for a(n).
  2. A binary tree's height h is defined recursively: a single node (no children) has height 0, and a tree with children has height 1 + max(height of left subtree, height of right subtree). Explain why this is a recursive definition and identify its base case.
  3. The "tower of folders" model from this section computes the total number of files in a folder using recursion. Write, in your own words, what the base case of FileCount is, and explain what would go wrong if the algorithm had no base case.
  4. A recurrence relation for an algorithm's runtime is T(n) = T(n−1) + n with T(1) = 1. Compute T(2), T(3), and T(4). Based on the pattern, what familiar formula does T(n) resemble?

Modeling with Algorithms

Algorithms are not just tools for programmers. They are precise mathematical objects — specifications of how a computation should proceed. Modeling a problem algorithmically means asking: given any valid input, what is the exact procedure that produces the correct output?

Algorithmic Modeling in Practice

A librarian wants to find all books in a catalog that were published between 2010 and 2020 AND have a rating above 4.0. This is a filtering task. The algorithm is:

Filter(catalog, start_year, end_year, min_rating): result = empty list for each book in catalog: if book.year >= start_year AND book.year <= end_year AND book.rating > min_rating: add book to result return result

The algorithm runs in O(n) time, where n is the number of books. The logical condition uses conjunction (AND), studied in Chapter 2.

Efficiency as a Design Goal

When modeling a problem algorithmically, efficiency is a consideration from the beginning. Two algorithms may both give correct answers but differ dramatically in speed as input grows. Chapter 12 showed that the difference between \( O(n \log n) \) sorting and \( O(n^2) \) sorting becomes enormous for large n. Choosing the right algorithm is itself a modeling decision.

Example 14.8.1
Designing and analyzing an algorithm
  • ProblemGiven a list of n integers, determine whether the list contains any duplicates.
  • ThinkThere are several approaches. The simplest is to compare every pair, but this is slow — \( O(n^2) \). A better approach uses sorting: sort the list, then check adjacent elements for equality.
  • Algorithm HasDuplicate(list): sort(list) // Sort in nondecreasing order for i = 1 to n-1: if list[i] = list[i+1]: return TRUE // Found a duplicate return FALSE // No duplicate found
  • Trace Let the input be [5, 3, 8, 3, 1]. After sorting: [1, 3, 3, 5, 8] Check adjacent pairs: 1 and 3: not equal 3 and 3: equal → return TRUE
  • CheckIf a duplicate exists, it will appear as adjacent elements after sorting, so the algorithm will find it. If no duplicate exists, all adjacent pairs differ, and the algorithm correctly returns FALSE. ✓ Sorting takes \( O(n \log n) \) time; the loop takes \( O(n) \) time. Total: \( O(n \log n) \), far better than the \( O(n^2) \) brute-force comparison of every pair.
Answer: The algorithm correctly detects duplicates in O(n log n) time by sorting the list and checking adjacent elements.
Practice 14.8Modeling with Algorithms
  1. Write pseudocode for an algorithm that takes a list of n numbers and returns the largest value. Trace your algorithm on the input [4, 9, 2, 7, 9, 1]. What is its time complexity?
  2. A teacher wants to find all students who scored above 90 on a test AND attended every class. Write pseudocode for this filtering task, and identify its time complexity in terms of the number of students n.
  3. Explain why sorting a list before searching for duplicates is more efficient than comparing every pair of elements directly. Use Big-O notation in your explanation.
  4. A vending machine algorithm checks whether a customer has inserted enough money for an item, then dispenses the item and returns change. Identify the precondition and postcondition for this algorithm.

Modeling with Modular Arithmetic

Modular arithmetic models any system where quantities wrap around — clocks, calendars, cyclic codes, and cryptographic systems. It provides the mathematical foundation for much of modern computing security.

Checksums and Error Detection

When data is transmitted over a network, errors can occur. A checksum is a value computed from a block of data and appended to it. The receiver recomputes the checksum and checks whether it matches. If not, an error occurred.

One simple checksum: sum all the bytes in a data block, then take the result modulo 256 (since a byte holds values 0–255). If data = [72, 101, 108, 108, 111], the sum is \( 72 + 101 + 108 + 108 + 111 = 500 \). The checksum is \( 500 \bmod 256 = 244 \). If any byte changes during transmission, the checksum is very likely to differ, revealing the error.

Cryptographic Applications

RSA encryption — one of the most widely used encryption systems in the world — is built entirely on modular arithmetic and the difficulty of factoring large integers. The key insight: computing \( m^e \bmod n \) is efficient using modular exponentiation (Chapter 6), but reversing this process without knowing the factorization of n is computationally infeasible for large n.

Not a Coincidence

The security of RSA rests on a theorem from number theory proved using modular arithmetic. Discrete mathematics is not an optional supplement to cryptography — it is the foundation.

Example 14.9.1
Modular arithmetic in a cyclic schedule
  • ProblemA hospital assigns nurses to three shifts: morning (shift 0), afternoon (shift 1), and night (shift 2). Shifts rotate in order. If a nurse is currently on shift 1 (afternoon), what shift will she be on in 47 days?
  • ThinkShifts cycle through 0, 1, 2, 0, 1, 2, .... This is modular arithmetic with modulus 3. Starting from shift 1, after d days, the shift is (1 + d) mod 3.
  • Solve (1 + 47) mod 3 = 48 mod 3 Since \( 48 = 16 \times 3 + 0 \), we have \( 48 \bmod 3 = 0 \).
  • CheckVerify with small cases: after 0 days, shift 1. After 1 day, shift 2. After 2 days, shift 0. After 3 days, shift 1 again — the cycle returns to shift 1 every 3 days. After 47 days, \( (1+47) \bmod 3 = 48 \bmod 3 = 0 \), which is the morning shift. ✓
Answer: In 47 days, the nurse will be on shift 0 (morning shift).
Practice 14.9Modeling with Modular Arithmetic
  1. A data block has bytes [200, 50, 6]. Using the checksum method from this section (sum modulo 256), compute the checksum. If the second byte changes from 50 to 51, what is the new checksum?
  2. Today is day 0 of a 7-day rotating cleaning schedule with assignments for days 0 through 6. What assignment number applies on day 100? Show your modular arithmetic.
  3. Explain, in your own words, why computing \( m^e \bmod n \) is described as "efficient" while reversing the process is "computationally infeasible" for large n. What earlier chapter's algorithm makes the forward computation efficient?
  4. A clock shows hours 1 through 12. If it is currently 9 o'clock, what time will it show in 50 hours? Express your reasoning using modular arithmetic with modulus 12.

Modeling with Boolean Algebra

Boolean algebra is the algebraic system underlying all digital logic. Every decision made by a computer — every branch, every comparison, every gate in a circuit — is governed by Boolean operations on binary values.

Boolean Models in Software

A web application decides whether to show a user an advertisement based on three conditions:

Defining the Conditions

p = "the user is not a premium subscriber"

q = "the user's location is in a supported region"

r = "the user has not opted out of ads"

The advertisement is shown when \( p \land q \land r \) is true. A software engineer can simplify compound conditions, design test cases by constructing the truth table, or redesign the logic by applying Boolean laws.

For example, if the company also decides that premium subscribers in supported regions without opt-out should see a different type of notice, the condition for showing the alternate notice might be \( \neg p \land q \land r \).

These two conditions, \( p \land q \land r \) and \( \neg p \land q \land r \), cover non-overlapping cases and together equal \( q \land r \) (when the region is supported and the user has not opted out, regardless of subscriber status). This simplification reduces the number of conditions the system must check.

Boolean Models in Hardware

At the hardware level, every computation is performed by circuits built from logic gates: AND, OR, NOT, NAND, NOR, and XOR. Designing efficient circuits means minimizing the number of gates, which corresponds to simplifying Boolean expressions. The techniques from Chapter 13 — applying De Morgan's Laws, distribution, absorption, and other Boolean identities — directly reduce circuit cost.

Example 14.10.1
Simplifying a Boolean decision
  • ProblemA smart thermostat activates heating when the following condition holds: the temperature is below 65°F AND either the time is between 6am and 10pm OR the manual override is active. Let p = "temperature is below 65°F," q = "time is between 6am and 10pm," r = "manual override is active." The activation condition is \( p \land (q \lor r) \). Write the equivalent disjunctive form and describe when each part activates heating.
  • ThinkApply the distributive law of Boolean algebra to expand the expression.
  • Solve p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
  • Interpret Heating activates if:
    • \( p \land q \): temperature is below 65°F AND it is within the normal operating hours, OR
    • \( p \land r \): temperature is below 65°F AND the manual override is active.
  • CheckThe two forms are logically equivalent by the distributive law of Boolean algebra (Chapter 13). ✓
Answer: p ∧ (q ∨ r) is equivalent to (p ∧ q) ∨ (p ∧ r). Heating turns on when it is cold during scheduled hours, or when it is cold and the override is manually activated.
Practice 14.10Modeling with Boolean Algebra
  1. A security light turns on when it is dark AND (motion is detected OR a manual switch is pressed). Write this condition using p, q, r, then expand it using the distributive law and interpret each resulting term.
  2. Simplify the Boolean expression \( (p \land q) \lor (p \land \neg q) \) using a Boolean identity from Chapter 13. What single condition does the simplified expression represent?
  3. A circuit outputs 1 if and only if at least two of its three inputs x, y, z are 1 ("majority vote"). Write a Boolean expression for this output using AND, OR, and NOT.
  4. Explain, using the thermostat example as a model, why simplifying a Boolean expression can reduce the cost of a circuit. What does "cost" mean in this context?
Sections 14.11 – 14.15
Capstone Design, Communication, and the Road Ahead
Capstone Projects · Communicating Reasoning · Discrete Math in CS and Data · Common Mistakes · Readiness for What's Next

Capstone Project Design

A capstone problem in discrete mathematics is a problem that is complex enough to require multiple discrete tools used in combination. This section describes how to approach such problems and provides a framework for designing your own capstone project.

What Makes a Good Capstone Problem

A good capstone problem has the following features. It involves a real system or a clearly described fictional system. It requires you to identify which discrete structures are relevant. It involves at least two distinct discrete tools from different parts of the course. It requires both computation — a calculation, an algorithm trace, a truth table — and reasoning — a proof, a justification, an explanation. It has a clear question with a verifiable answer. And it connects to applications in computer science, cybersecurity, scheduling, networks, databases, or another applied domain.

Sample Capstone Scenario: Secure File Sharing Network

A small organization uses a file-sharing network with 6 computers: C1, C2, C3, C4, C5, and C6. Direct connections exist between C1–C2, C1–C3, C2–C4, C3–C4, C4–C5, and C5–C6. Each connection has a transmission time in milliseconds: C1–C2 takes 3ms, C1–C3 takes 5ms, C2–C4 takes 2ms, C3–C4 takes 4ms, C4–C5 takes 1ms, and C5–C6 takes 2ms.

Access to any file requires a 4-digit PIN where each digit is chosen from {1, 2, 3, 4, 5, 6, 7, 8} and no digit is repeated.

The system logs access using the rule: "Flag a session if the user is NOT authenticated AND has made more than 3 failed attempts."

Diagram Instruction

Draw six vertices C1 through C6. Draw weighted edges: C1–C2 (3), C1–C3 (5), C2–C4 (2), C3–C4 (4), C4–C5 (1), C5–C6 (2). The graph forms a shape with two paths from C1 to C4 (through C2 or through C3), then a single chain from C4 through C5 to C6. Label each edge with its transmission time.

Questions for a Capstone Project

1. Graph theory — Draw the network as a weighted graph. Find the shortest path (minimum total transmission time) from C1 to C6.

2. Counting — How many valid PINs are possible?

3. Logic — Write the flagging condition as a logical expression. Find an equivalent form using De Morgan's Laws. State precisely under what conditions a session is NOT flagged.

4. Proof — Prove or disprove: every computer in the network can reach every other computer.

5. Algorithms — Write pseudocode for an algorithm that checks a proposed PIN for validity (4 digits, each from {1,...,8}, no repeats). Analyze its time complexity.

6. Modular arithmetic — The organization assigns each file a checksum computed as the sum of the ASCII values of its filename characters, taken modulo 64. If a filename has ASCII values 72, 101, 108, 108, what is the checksum?

This scenario integrates graph theory, counting, logic, proof, algorithms, and modular arithmetic in a single setting. Each question can be answered independently, but together they describe a coherent system.

Capstone Project Framework

When building your own capstone project, use the following framework.

  1. Describe the system. Write 2–3 sentences describing the setting: what it is, who uses it, and what it does.
  2. Identify the objects. List the discrete objects in the system: nodes, records, users, tasks, passwords, messages, and so on.
  3. Identify the structure. What relationships, rules, or connections govern the objects? Are they graph edges, set membership conditions, logical rules, ordered sequences?
  4. Write at least four questions that use at least three different discrete tools.
  5. Solve each question using the Read → Represent → Reason → Solve → Check → Explain method.
  6. Write a brief reflection describing which tool was most important in each question and how the tools connected to each other.
Practice 14.11Capstone Design Practice
  1. Answer Question 2 from the Secure File Sharing Network scenario: how many valid PINs are possible? Show your reasoning.
  2. Answer Question 6 from the Secure File Sharing Network scenario: compute the checksum for the filename with ASCII values 72, 101, 108, 108.
  3. Using the framework in this section, write the first three steps (describe the system, identify the objects, identify the structure) for a capstone project of your own choosing — for example, a library checkout system, a ride-sharing app, or a school attendance system.

Communicating Discrete Reasoning

Mathematics is not complete when you reach a numerical answer or draw a diagram. Mathematics is complete when you can explain your reasoning clearly enough that another person can follow it, verify it, and trust it.

Discrete mathematics, in particular, depends on precise communication. A proof that cannot be followed is not a proof. An algorithm that cannot be understood cannot be trusted. A model that cannot be explained cannot be evaluated.

This section describes the key elements of clear mathematical communication.

State What You Are Doing

Before beginning a proof, a calculation, or a model, state what you are about to show and which method you will use. This is not bureaucratic formality — it gives the reader a map of your reasoning.

Example

Instead of jumping into symbol manipulation, write: "We will prove by direct proof that the product of two odd integers is odd."

Define Every Non-Obvious Term

If you introduce a variable or symbol, say what it represents. If you use a concept that might be ambiguous, define it precisely.

Example

Instead of saying "let G be the graph," write: "Let G be the undirected graph with vertex set V = {A, B, C, D} and edge set E = {A–B, B–C, C–D}."

Show Your Steps

Do not skip steps in proofs, counting arguments, or algorithm traces. The value of discrete mathematics is in the reasoning, not just the answer. Each step should follow from the previous one by a named rule, definition, theorem, or logical deduction.

Interpret Your Answer

After reaching a conclusion, explain what it means in the context of the original problem. A count of 840 is not an answer until you say "there are 840 ways to form the two groups and designate a leader."

Separate Computation from Explanation

In a proof or a modeling exercise, it is helpful to keep computations — symbol manipulation, arithmetic, algorithm traces — separate from explanations: why a step is valid, what a result means, which theorem you applied. This makes it easier for a reader to follow the argument.

Write for an Audience

Imagine you are writing for a student who knows the definitions but has not seen this particular problem. Your explanation should be complete enough that they could follow it without help.

Practice 14.12Communicating Discrete Reasoning
  1. Rewrite the following sentence to state the method before beginning: "Suppose n is even. Then n = 2k for some integer k. So n² = 4k², which is even."
  2. A classmate writes "the answer is 120" with no further explanation for a counting problem about arranging 5 books on a shelf. Rewrite this as a complete answer, including interpretation.
  3. Explain, in your own words, why "It is clear that the pattern continues" is not an acceptable substitute for a proof, even if the pattern does continue.

Discrete Mathematics in Computer Science, Security, and Data

This section briefly surveys how each major area of discrete mathematics appears in the fields that students entering computer science, cybersecurity, data science, cryptography, and related disciplines will encounter.

Algorithms and Data Structures

Algorithms and data structures are the direct application of the ideas in Chapters 4, 5, 9, 11, and 12. Proof methods (Chapter 4) are used to verify that algorithms are correct. Induction and recursion (Chapter 5) are used to analyze recursive algorithms and define recursive data structures such as linked lists, trees, and heaps. Recurrence relations (Chapter 9) are used to find the runtime of divide-and-conquer algorithms. Graph algorithms (Chapter 11) are the foundation of network routing, web crawling, scheduling, and dependency resolution. Big-O notation (Chapter 12) is the standard language for comparing algorithm efficiency.

Databases

Relational databases are built on set theory and relations (Chapter 3). Queries use set operations — union, intersection, difference, and Cartesian product — under the formal name of relational algebra. Logic (Chapter 2) governs the WHERE clause of a database query. Graph databases use graph theory (Chapter 10) to model and query networks of connected data.

Cryptography and Cybersecurity

Modern cryptographic systems rely on modular arithmetic (Chapter 6) and number theory. Public-key cryptography — including RSA — depends on modular exponentiation, the difficulty of factoring large integers, and Bézout's identity. Hash functions use modular arithmetic to produce fixed-size outputs from variable-size inputs. Access control logic (Chapter 2) governs who is allowed to see, modify, or transmit data. Boolean algebra and circuit design (Chapter 13) are foundational to hardware security and side-channel analysis.

Artificial Intelligence and Machine Learning

The reasoning structures of AI are discrete. Decision trees use graph theory (Chapter 10). Probabilistic reasoning uses counting-based probability (Chapter 8). State machines and planning algorithms use graph traversal (Chapter 11). Logical inference systems (Chapter 2) are the backbone of rule-based AI. Many optimization algorithms in machine learning rely on combinatorial search through a discrete space.

Programming and Software Engineering

Programmers use logic (Chapter 2) every time they write a conditional statement or a loop condition. Sets and relations (Chapter 3) appear in every data model. Recursion (Chapter 5) is used in parsing, tree traversal, and divide-and-conquer algorithms. Boolean algebra (Chapter 13) appears in flag management, access conditions, and hardware-level programming. Algorithm analysis (Chapter 12) is essential for writing software that scales.

Practice 14.13Connections to Computer Science and Data
  1. Choose one field from this section (algorithms, databases, cryptography, AI, or software engineering) and identify two chapters from this textbook that you believe will be most directly useful in that field. Justify your choices.
  2. Explain, in two or three sentences, why "relational algebra" is an appropriate name for the set of operations used in database queries.
  3. Give an example, different from those in this section, of a situation in artificial intelligence or machine learning where graph theory might be used.

Common Discrete Modeling Mistakes

Even students who understand individual topics can make errors when applying discrete mathematics to real problems. This section identifies the most frequent mistakes.

Mistake 1 — Choosing the Wrong Structure
A student is asked to find the number of ways to arrange 5 different tasks in a schedule, and computes C(5,3) instead of 5! or a permutation formula.

Why it happens: the student confuses a selection problem (choosing which objects) with an arrangement problem (ordering the objects).

Fix: Before computing, ask — does order matter? If yes, use permutations. If no, use combinations. Revisit Section 8.6.
Mistake 2 — Forgetting Base Cases in Recursion and Induction
A student writes a recursive algorithm but forgets to specify what happens when the input is empty or of size 1. The algorithm runs forever or crashes.

Why it happens: students focus on the recursive step and assume the base case is obvious.

Fix: Always identify and state every base case before writing the recursive step.
Mistake 3 — Confusing Graph Edges and Vertices
A student is asked to find the number of edges in a complete graph K₅ and counts 5 instead of 10.

Why it happens: the student counts vertices, not edges.

Fix: In Kₙ, every pair of vertices is connected by an edge. The number of edges is C(n, 2).
Mistake 4 — Applying Modular Arithmetic Without Reducing
A student computes 17³ mod 5 by computing 17³ = 4913 and then reducing, but makes an arithmetic error.

Better approach: reduce the base first. 17 ≡ 2 (mod 5). Then 17³ ≡ 2³ = 8 ≡ 3 (mod 5). Smaller numbers, same answer.

Fix: When computing modular exponentiation, reduce the base modulo n before raising to a power.
Mistake 5 — Informal Proof Claims
A student writes "It is clear that this formula holds for all n" without providing a proof.

Why it happens: the pattern seems obvious from examples.

Fix: Examples verify specific cases; only a proof establishes a general claim. Use the appropriate proof method — direct, contrapositive, contradiction, or induction.
Mistake 6 — Treating All Connections as Undirected
A student models a prerequisite system as an undirected graph. Course A must be taken before Course B, but the student draws an edge A–B without direction, making the model ambiguous about which order is required. Fix: When relationships have direction (must come before, sends data to, is a parent of), use a directed graph (digraph). Revisit Section 10.3.
Mistake 7 — Double-Counting
A student counts the number of handshakes in a room of 10 people by computing 10 × 9 = 90, forgetting that each handshake is counted twice (once for each participant). Fix: For unordered pairs, divide by 2: (10 × 9) / 2 = 45. Or use the combination formula C(10, 2) = 45.
Mistake 8 — Confusing Logical AND and OR
A student is told: "A user may access the system if they are an employee AND have clearance." The student encodes this as an OR condition, inadvertently allowing access to employees without clearance or non-employees with clearance. Fix: Read the access condition carefully. "AND" requires both conditions to be true. "OR" requires at least one to be true. In security systems, incorrect logical connectives can create serious vulnerabilities.
Practice 14.14Error Analysis
  1. A student is asked: "How many 3-element subsets can be formed from the set {1, 2, 3, 4, 5}?" The student computes 5 × 4 × 3 = 60. Identify the mistake and write the correct answer.
  2. A student is asked to prove that "for all integers n, if n² is even then n is even." The student writes: "Let n = 4. Then n² = 16, which is even, and n = 4 is even. Therefore the claim is true." Identify the mistake and explain what proof method would actually establish this claim.
  3. A student models a one-way road network (where some roads can only be traveled in one direction) as an undirected graph and then uses Euler's theorem to find an Euler circuit. Identify the mistake.
  4. A student writes a recursive function Sum(n): return n + Sum(n-1) and claims this correctly computes 1 + 2 + ... + n for any positive integer n. What is missing, and what happens when the function runs?

Readiness for Advanced Computer Science and Higher Mathematics

Completing a rigorous course in discrete mathematics is significant preparation. This final section names the courses and topics that build directly on the ideas from this book.

Algorithms (Computer Science)

A course in algorithms develops the themes of Chapters 11 and 12 in depth. You will study sorting algorithms (merge sort, heap sort, quicksort), graph algorithms (breadth-first search, depth-first search, shortest paths, spanning trees), dynamic programming, greedy algorithms, and NP-completeness. The language of proofs (Chapter 4), induction (Chapter 5), recurrence relations (Chapter 9), and Big-O notation (Chapter 12) will all be required tools.

Data Structures (Computer Science)

A course in data structures develops the themes of Chapters 5, 10, and 11 in depth. You will study linked lists, stacks, queues, trees, heaps, hash tables, and graphs as programmable structures. Recursive definitions (Chapter 5), graph theory (Chapter 10), and trees (Chapter 11) are foundational.

Theory of Computation (Computer Science)

A course in theory of computation formalizes what is computable, what is not, and how to prove either. It uses logic (Chapter 2), sets (Chapter 3), proof (Chapter 4), induction (Chapter 5), and graph theory (Chapter 10). The ideas of Chapter 12 — what algorithms can and cannot do efficiently — connect directly to the P versus NP problem.

Cryptography (Computer Science / Mathematics)

A course in cryptography develops the themes of Chapter 6 in depth, adding group theory, prime factorization, discrete logarithms, elliptic curves, and protocol design. Every major cryptographic primitive — RSA, Diffie-Hellman, AES — rests on modular arithmetic and number theory.

Combinatorics (Mathematics)

An advanced combinatorics course extends the counting of Chapters 7, 8, and 9 into generating functions, Ramsey theory, Latin squares, coding theory, and extremal combinatorics. The proof techniques of Chapters 4 and 5 are used throughout.

Linear Algebra (Mathematics)

Linear algebra studies vectors, matrices, and linear transformations. The graph adjacency matrices of Chapter 10 are a direct connection point. Proofs in linear algebra use the same methods as Chapter 4. The logic of this book prepares students to read mathematical definitions and theorems carefully.

Probability and Statistics (Mathematics / Computer Science)

The discrete probability of Chapter 8 is the starting point for a full probability course. Advanced probability extends to continuous distributions (requiring calculus), but the logical foundations — sample spaces, events, conditional probability, expectation — are all rooted in the counting and set theory of this book.

Artificial Intelligence (Computer Science)

Introductory AI courses use graph search (Chapter 11), logic-based reasoning (Chapter 2), Bayesian reasoning (Chapter 8), algorithm design (Chapter 12), and discrete optimization. The readiness developed in this book is directly applicable.

Practice 14.15Looking Ahead
  1. Choose two courses from this section that interest you most. For each, identify one specific topic from this textbook that you expect to use again, and explain why.
  2. Explain, in your own words, the connection between Chapter 12 (Algorithms and Complexity) and the "P versus NP problem" mentioned in the Theory of Computation description. You do not need to define P or NP precisely — describe what kind of question you expect it to be, based on what you know about algorithm efficiency.
  3. A student says, "I'm interested in data science, so discrete mathematics isn't relevant to me — I should have taken statistics instead." Write a short response (3–5 sentences) addressing this claim, using specific connections from this chapter.
MGU Library Connection

The MGU Library includes companion pages for Advanced Algorithms, Cryptography Foundations, Data Structures, Theory of Computation, and Discrete Probability. Students who complete this textbook are ready for all of these paths. Use the MGU Mathematics Series pathway guide to plan your next steps.