Discrete Mathematics Foundations
Welcome to this comprehensive course on fundamental concepts in discrete mathematics, a cornerstone of computer science and algorithm design. In this module we will explore seven key topics…

Given the proposition p → q, which of the following is logically equivalent to it?
What is the greatest common divisor of 60 and 18 according to the divisibility diagram?
If a and b are integers with gcd(a,b)=1, which statement about modular inverses is true?
How many 8‑bit binary strings contain exactly three 1's?
Which of the following is a correct application of the Division Algorithm for a = 101 and d = 11?
According to the Euclidean algorithm, what is gcd(7169, 7811)?
What does the principle of inclusion–exclusion (PIE) state for two overlapping sets A and B?
Which of the following correctly expresses the number of ways to choose k objects from n distinct objects?
In the context of graph theory, what does the Handshake Lemma assert?
Which of the following statements about the set of binary trees defined recursively is true?
Discrete Mathematics Foundations
Welcome to this comprehensive course on fundamental concepts in discrete mathematics, a cornerstone of computer science and algorithm design. In this module we will explore seven key topics that frequently appear in quizzes and exams: closure properties, logical equivalence, greatest common divisors, modular inverses, combinatorial counting, the Division Algorithm, the Euclidean Algorithm, and the Principle of Inclusion–Exclusion. Each section provides clear definitions, intuitive examples, and practice insights to help you master the material.
1. Closure Property of the Natural Numbers under Subtraction
The closure property states that applying an operation to elements of a set yields a result that is still within the same set. For the set of natural numbers ℕ = {0,1,2,…}, addition and multiplication are closed operations, but subtraction is not closed.
- Example:
5 – 3 = 2(still a natural number). - Counter‑example:
3 – 5 = -2(a negative integer, not in ℕ).
Therefore, the correct statement is: Subtracting two natural numbers may produce a non‑natural result, so ℕ is not closed under subtraction. This nuance is essential when designing algorithms that rely on natural‑number arithmetic; you must guard against underflow or explicitly handle negative results.
2. Logical Equivalence of Implications
In propositional logic, the implication p → q can be rewritten using logical operators. The standard equivalence is:
p → q ≡ ¬p ∨ q
Why does this hold? The truth table for p → q is false only when p is true and q is false. The disjunction ¬p ∨ q is also false only in that same case, making the two statements logically identical.
Other options such as ¬q → ¬p (the contrapositive) are equivalent to p → q as well, but the quiz asked for a direct equivalence using only basic operators, which is ¬p ∨ q.
3. Computing the Greatest Common Divisor (GCD)
The greatest common divisor of two integers is the largest integer that divides both without remainder. For the pair (60, 18), factor each number:
- 60 = 2²·3·5
- 18 = 2·3²
The common prime factors are 2 and 3, each appearing to the lowest power present in both factorizations (2¹ and 3¹). Multiplying these gives gcd(60,18) = 2·3 = 6. This result can also be obtained quickly with the Euclidean algorithm, a method we will explore in detail later.
4. Modular Inverses and Coprime Integers
When two integers a and b satisfy gcd(a,b) = 1, they are said to be coprime. A fundamental theorem in number theory tells us that a modular inverse of a modulo b exists precisely under this condition.
Formally, there exists an integer b' such that:
a·b' ≡ 1 (mod b)
This inverse can be found using the Extended Euclidean Algorithm, which not only computes the gcd but also provides coefficients x and y satisfying ax + by = gcd(a,b) = 1. The coefficient x (mod ) is the modular inverse of a.
5. Counting Binary Strings with a Fixed Number of Ones
Binary strings of length n consist of 0s and 1s. To count strings that contain exactly k ones, we use the binomial coefficient:
\(\binom{n}{k}\) = number of ways to choose k positions for the ones.
For an 8‑bit string with exactly three 1’s:
\(\binom{8}{3} = \frac{8·7·6}{3·2·1} = 56\).
This combinatorial principle underlies many algorithmic problems, such as generating combinations, calculating Hamming distances, and designing error‑correcting codes.
6. The Division Algorithm
The Division Algorithm states that for any integers a (the dividend) and d > 0 (the divisor), there exist unique integers q (quotient) and r (remainder) such that:
a = d·q + r with 0 ≤ r < d.
Applying this to a = 101 and d = 11:
- Divide 101 by 11 → quotient 9, remainder 2 (because 11·9 = 99 and 101 – 99 = 2).
Thus the correct representation is 101 = 11·9 + 2. This theorem is the foundation of integer division in programming languages and is used extensively in hashing, modular arithmetic, and algorithm analysis.
7. The Euclidean Algorithm for GCD
The Euclidean algorithm repeatedly applies the identity gcd(a,b) = gcd(b, a mod b) until the remainder becomes zero. Let’s compute gcd(7169, 7811) step by step:
- 7811 mod 7169 = 642 (because 7811 = 7169·1 + 642).
- 7169 mod 642 = 107 (7169 = 642·11 + 107).
- 642 mod 107 = 0 (642 = 107·6 + 0).
The last non‑zero remainder is 107, so gcd(7169,7811) = 107. Mastery of this algorithm is crucial for cryptographic protocols (e.g., RSA) and for simplifying fractions in algorithmic computations.
8. Principle of Inclusion–Exclusion (PIE) for Two Sets
The Principle of Inclusion–Exclusion provides a way to count the size of a union of overlapping sets without double‑counting elements that belong to both. For two sets A and B:
|A ∪ B| = |A| + |B| – |A ∩ B|
Why subtract the intersection? When we add |A| and |B|, any element that lies in both sets is counted twice. Subtracting |A ∩ B| corrects this overcount. This principle extends to three or more sets, with alternating addition and subtraction of higher‑order intersections.
Summary and Study Tips
These eight concepts form a solid base for tackling more advanced topics in algorithmics and theoretical computer science. Here are some actionable tips for reinforcing your understanding:
- Practice proofs: Write short proofs for closure properties and logical equivalences to internalize the reasoning.
- Implement algorithms: Code the Euclidean and Extended Euclidean algorithms in your favorite language; observe how they produce both gcd and modular inverses.
- Use combinatorial formulas: Solve a variety of counting problems (binary strings, subsets, permutations) to become comfortable with binomial coefficients.
- Apply PIE: Work through problems involving overlapping groups (e.g., survey data) to see the inclusion–exclusion principle in action.
- Check edge cases: For division and modular arithmetic, always verify that the remainder satisfies
0 ≤ r < d.
By mastering these fundamentals, you’ll be well‑prepared for more complex algorithmic challenges, such as number‑theoretic cryptography, graph theory, and combinatorial optimization.
