Discrete Structures · Unit 5 · 9 hrs
Counting and Discrete Probability
Exam-focused notes for Counting and Discrete Probability (Discrete Structures, CSC165): what the TU syllabus asks and how it has actually been tested, with 14 solved past questions from this unit.
Counting and Discrete Probability in short
This chapter develops combinatorics, the branch of discrete mathematics that counts arrangements of objects without listing them all, along with discrete probability built directly on those counts, and the recurrence relations that describe quantities defined in terms of earlier values of themselves.
What this unit covers
- Counting
- Basics of Counting
- Pigeonhole Principle
- Permutations and Combinations
- Two Element Subsets
- Counting Subsets of a Set
- Binomial Coefficients
- Generalized Permutations and Combinations
- Generating Permutations and Combinations
- Discrete Probability
- Introduction to Discrete Probability
- Probability Theory
- Probability Calculation in Hashing
- Expected Value and Variance
- Randomized Algorithms
- Advanced Counting
- Recurrence Relations
- Solving Recurrence Relations (Homogeneous and Non-Homogeneous equations)
- Introduction to Divide and Conquer Recurrence Relations
Pigeonhole Principle
2081 · 5 marks
State sum rule and product rule. If 26 integers are chosen from the set of consecutive integers {1,2,3,...,50}, prove that there are sure to be two numbers so that one is multiple of the other. [5]
2080 · 10 marks
State pigeonhole principle. Solve the recurrence relation $a_n = 5a_{n-1} - 6a_{n-2}$, with initial conditions $a_1 = 1$ and $a_2 = 3$.[10]
2078 · 5 marks
Show that if there are 30 students in a class, then at least two have same names that begin with the same letter. Explain the pascal's triangle. [5]
Show solved answerHide answer
Pigeonhole Principle and Pascal's Triangle
Given Data
- Number of students = 30
- Number of letters in the English alphabet = 26
Part 1: At Least Two Students Have Names Beginning with the Same Letter
Principle Used: Pigeonhole Principle
Statement: If $n$ objects are placed into $k$ boxes and $n > k$, then at least one box contains two or more objects.
More generally, if $n$ objects are placed into $k$ boxes, then at least one box contains at least $\left\lceil \dfrac{n}{k} \right\rceil$ objects.
Proof
Set up the correspondence:
- Pigeonholes (boxes): the 26 letters of the alphabet that a name can begin with. So $k = 26$.
- Pigeons (objects): the 30 students, each classified by the first letter of their name. So $n = 30$.
Since
$$n = 30 > 26 = k,$$
by the Pigeonhole Principle at least one letter (box) must be assigned to more than one student.
Using the generalized form, the most crowded letter contains at least
$$\left\lceil \frac{30}{26} \right\rceil = \lceil 1.153\ldots \rceil = 2 \text{ students.}$$
Conclusion: At least two students have names beginning with the same letter. (Proved)
Worst case reasoning: Even if the first 26 students all get distinct starting letters, the remaining $30 - 26 = 4$ students must reuse letters already taken, forcing a repetition.
Part 2: Pascal's Triangle
Definition
Pascal's Triangle is a triangular array of the binomial coefficients $\binom{n}{r}$, where each interior entry equals the sum of the two entries directly above it.
Construction Rule
$$\binom{n}{r} = \binom{n-1}{r-1} + \binom{n-1}{r}$$
with boundary conditions
$$\binom{n}{0} = 1, \qquad \binom{n}{n} = 1 \quad \text{for all } n \ge 0.$$
The Triangle (First 6 rows)
Row 0: 1
Row 1: 1 1
Row 2: 1 2 1
Row 3: 1 3 3 1
Row 4: 1 4 6 4 1
Row 5: 1 5 10 10 5 1
Key Properties
| Property | Description |
|---|---|
| Symmetry | $\binom{n}{r} = \binom{n}{n-r}$ |
| Row Sum | $\displaystyle\sum_{r=0}^{n}\binom{n}{r} = 2^{n}$ |
| Binomial Theorem | Row $n$ gives coefficients of $(x+y)^n$ |
| Borders | All edge entries equal $1$ |
Application: Binomial Theorem
$$(x+y)^n = \sum_{r=0}^{n}\binom{n}{r} x^{n-r} y^{r}$$
Using Row 3:
$$(x+y)^3 = x^3 + 3x^2y + 3xy^2 + y^3$$
Verification of the addition rule
$$\binom{4}{2} = \binom{3}{1} + \binom{3}{2} = 3 + 3 = 6,$$
which matches the middle entry of Row 4.
Summary: With 30 students and only 26 possible initial letters, the Pigeonhole Principle guarantees at least two students share a starting letter. Pascal's Triangle arranges the binomial coefficients so each value is the sum of the two above it, encoding the coefficients of $(x+y)^n$.
Solving Recurrence Relations
2081 · 5 marks
Solve the recurrence relation $a_n = a_{n-1} + 2a_{n-2}$ with initial conditions $a_0 = 2$ and $a_1 = 7$. [5]
Show solved answerHide answer
Solving the Recurrence Relation $a_n = a_{n-1} + 2a_{n-2}$
Given Data
- Recurrence: $a_n = a_{n-1} + 2a_{n-2}$
- Initial conditions: $a_0 = 2$, $a_1 = 7$
Step 1: Characteristic Equation
This is a linear homogeneous recurrence with constant coefficients. Assume $a_n = r^n$:
$$r^n = r^{n-1} + 2r^{n-2}$$
Divide by $r^{n-2}$:
$$r^2 = r + 2 \implies r^2 - r - 2 = 0$$
Step 2: Solve for Roots
$$r^2 - r - 2 = (r-2)(r+1) = 0$$
$$r_1 = 2, \quad r_2 = -1$$
Distinct roots, so the general solution is:
$$a_n = \alpha_1 (2)^n + \alpha_2 (-1)^n$$
Step 3: Apply Initial Conditions
From $a_0 = 2$: $$\alpha_1 + \alpha_2 = 2 \quad (i)$$
From $a_1 = 7$: $$2\alpha_1 - \alpha_2 = 7 \quad (ii)$$
Adding $(i)$ and $(ii)$: $$3\alpha_1 = 9 \implies \alpha_1 = 3$$
From $(i)$: $$\alpha_2 = 2 - 3 = -1$$
Step 4: Final Solution
$$\boxed{a_n = 3 \cdot 2^n - (-1)^n}$$
Verification
| $n$ | Formula | Expected |
|---|---|---|
| $0$ | $3(1) - 1 = 2$ | $2$ ✓ |
| $1$ | $3(2) - (-1) = 7$ | $7$ ✓ |
| $2$ | $3(4) - 1 = 11$ | $7 + 2(2) = 11$ ✓ |
The solution is confirmed correct.
2078 · 5 marks
Solve the recurrence relation $a_n = 5a_{n-1} - 6a_{n-2}$, with initial conditions $a_0 = 1$, $a_1 = 4$. [5]
Show solved answerHide answer
Solution of Recurrence Relation
Given
$$a_n = 5a_{n-1} - 6a_{n-2}, \quad a_0 = 1,\ a_1 = 4$$
Solution
Characteristic equation. Assume $a_n = r^n$:
$$r^2 = 5r - 6 \implies r^2 - 5r + 6 = 0$$
Roots:
$$(r-2)(r-3) = 0 \implies r_1 = 2,\ r_2 = 3$$
Distinct roots, so the general solution is:
$$a_n = \alpha_1 \cdot 2^n + \alpha_2 \cdot 3^n$$
Apply initial conditions:
$n=0$: $\alpha_1 + \alpha_2 = 1 \quad (i)$
$n=1$: $2\alpha_1 + 3\alpha_2 = 4 \quad (ii)$
From $(i)$: $\alpha_1 = 1 - \alpha_2$. Substitute into $(ii)$:
$$2(1 - \alpha_2) + 3\alpha_2 = 4 \implies 2 + \alpha_2 = 4 \implies \alpha_2 = 2$$
$$\alpha_1 = 1 - 2 = -1$$
Final solution:
$$\boxed{a_n = 2\cdot 3^n - 2^n}$$
Verification:
| $n$ | $2\cdot3^n - 2^n$ | Check |
|---|---|---|
| 0 | $2-1=1$ | $a_0=1$ ✓ |
| 1 | $6-2=4$ | $a_1=4$ ✓ |
| 2 | $18-4=14$ | $5(4)-6(1)=14$ ✓ |
2076 · 10 marks
Question
State pigeonhole principle. Solve the recurrence relation $a_n = 3a_{n-1} - 3a_{n-2} + a_{n-3}$, with initial conditions $a_0 = 1, a_1 = 3, a_2 = 7$. [10]
2075 · 5 marks
Solve the recurrence relation $a_n = 5a_{n-1} - 6a_{n-2}$, with initial conditions $a_1 = 1$ and $a_2 = 2$. [5]
Show solved answerHide answer
Solution of Recurrence Relation
Given
- Recurrence: $a_n = 5a_{n-1} - 6a_{n-2}$
- Initial conditions: $a_1 = 1$, $a_2 = 2$
This is a linear homogeneous recurrence of degree 2 with constant coefficients.
Solution
Characteristic equation
Substitute $a_n = r^n$:
$$r^2 = 5r - 6 \implies r^2 - 5r + 6 = 0$$
Factor:
$$(r-2)(r-3) = 0 \implies r_1 = 2,\ r_2 = 3$$
Distinct roots, so the general solution is:
$$a_n = \alpha_1 \cdot 2^n + \alpha_2 \cdot 3^n$$
Apply initial conditions
For $a_1 = 1$: $$2\alpha_1 + 3\alpha_2 = 1 \quad (i)$$
For $a_2 = 2$: $$4\alpha_1 + 9\alpha_2 = 2 \quad (ii)$$
Multiply $(i)$ by 2: $$4\alpha_1 + 6\alpha_2 = 2 \quad (iii)$$
Subtract $(iii)$ from $(ii)$: $$3\alpha_2 = 0 \implies \alpha_2 = 0$$
From $(i)$: $$2\alpha_1 = 1 \implies \alpha_1 = \tfrac{1}{2}$$
Final solution
$$\boxed{a_n = \tfrac{1}{2}\cdot 2^n = 2^{n-1}}$$
Verification
| $n$ | $2^{n-1}$ | Recurrence |
|---|---|---|
| 1 | 1 | given |
| 2 | 2 | given |
| 3 | 4 | $5(2)-6(1)=4$ ✓ |
| 4 | 8 | $5(4)-6(2)=8$ ✓ |
The solution satisfies both the recurrence and initial conditions.
2080.1 · 10 marks
Linear Homogeneous Recurrence Relation with Constant Coefficients
A linear homogeneous recurrence relation with constant coefficients is a recurrence relation of the form:
$$a_n = c_1 a_{n-1} + c_2 a_{n-2} + \cdots + c_k a_{n-k}$$
where $c_1, c_2, \ldots, c_k$ are constants and $k$ is the order of the recurrence relation.
To solve such a recurrence relation, we use the characteristic equation method:
- Assume a solution of the form $a_n = r^n$
- Substitute into the recurrence relation to get the characteristic equation
- Solve for the roots $r$
- The general solution depends on the nature of the roots (distinct, repeated, or complex)
Permutations and Combinations
2081 · 5 marks
When do we use permutation rather than combination? How many 5-digit numbers can be generated using the digits 0 to 9, if each number starts with 98 and no digit appears more than once? [5]
2076 · 5 marks
How many 3 digits numbers can be formed from the digits 1,2,3,4 and 5 assuming that:a. Repetitions of digits are allowed b. Repetitions of digits are not allowed [5]
2075 · 5 marks
List any two applications of conditions of probability. You have 9 families you would like to incite to a wedding. Unfortunately, you can only invite 6 families. How many different sets of invitations could you write? [5]
Show solved answerHide answer
Applications of Conditional Probability and Combination Problem
Given Data
- Total families available: $n = 9$
- Families to be invited: $r = 6$
- Order does not matter (a set of invitations), so this is a combination problem.
Part 1: Two Applications of Conditional Probability
Conditional probability $P(A|B)$ is the probability of event $A$ occurring given that event $B$ has already occurred. Two applications:
-
Medical Diagnosis: Determining the probability that a patient actually has a disease given a positive test result, i.e., $P(\text{Disease} \mid \text{Positive Test})$. This is often computed using Bayes' theorem.
-
Spam Email Filtering: Classifying an email as spam given the presence of certain words, i.e., $P(\text{Spam} \mid \text{Keywords})$. Bayesian spam filters rely on this.
(Other valid examples: weather forecasting, risk assessment in insurance, fault diagnosis in machines.)
Part 2: Combination Problem
Formula
The number of ways to choose $r$ families from $n$ families, without regard to order:
$$C(n, r) = \binom{n}{r} = \frac{n!}{r!,(n-r)!}$$
Solution
$$C(9, 6) = \frac{9!}{6!,(9-6)!} = \frac{9!}{6!,\cdot,3!}$$
Expanding and cancelling $6!$:
$$= \frac{9 \times 8 \times 7 \times 6!}{6! \times (3 \times 2 \times 1)} = \frac{9 \times 8 \times 7}{6} = \frac{504}{6} = 84$$
Conclusion
There are $\boxed{84}$ different sets of invitations that could be written when choosing 6 families out of 9.
Binomial Coefficients
2078 · 5 marks
What is the coefficient of $x^2$ in $(1+x)^{11}$? Describe how relation can be represented using matrix. [5]
Randomized Algorithms
2075 · 5 marks
What does probability testing means? Describe how Fermat's Little Theorem tests for a prime number with suitable example. [5]
Basics of Counting
2080.1 · 5 marks
What is product rule? How many strings are there of four lowercase letters that have the letter x in them? [5]
Make Unit 5 stick
Practice CSC165 with flashcards & quizzes