Discrete Structure · Unit 7
Combinatorics and Counting
Exam-focused notes for Combinatorics and Counting (Discrete Structure, BIT152): what the TU syllabus asks and how it has actually been tested, with 8 solved past questions from this unit.
Combinatorics and Counting in short
Combinatorics is the art of counting without listing every case. It is used to count passwords, arrangements, selections and to estimate how much work an algorithm does.
What this unit covers
- Product rule
- Permutations
- Combinations
- Lexicographic ordering
- Pigeonhole principle
- Generalized pigeonhole principle
- Inclusion and exclusion principle
- Binomial coefficients
Generalized pigeonhole principle
2081 · 5 marks
State generalized Pigeonhole principle. How many ways can you draw four digits integers without repetition of the digit? [5]
2079 · 5 marks
What is generalized pigeonhole principle. If a class has 24 students, what is the maximum number of possible grading that must be done to ensure that there at least two students with the same grade. [5]
Show solved answerHide answer
Generalized Pigeonhole Principle
Given Data
- Number of students in class: $24$
- Grading system: standard grades assumed as ${A, B, C, D, F}$, so number of grade categories $k = 5$
- Required: number of gradings needed to guarantee at least two students share the same grade
Note: The number of distinct grades is not stated in the question. The standard university grading scheme with 5 grades (A, B, C, D, F) is assumed. If a different number of grades is intended, the answer changes accordingly.
Definition
Generalized Pigeonhole Principle:
If $N$ objects are placed into $k$ boxes, then at least one box contains at least $\left\lceil \dfrac{N}{k} \right\rceil$ objects.
Basic Pigeonhole Principle (special case): If $N > k$, then at least one box contains at least $2$ objects.
Solution
Here the grades are the pigeonholes and the students are the objects.
We want at least two students in the same grade category, i.e.
$$\left\lceil \frac{N}{k} \right\rceil \geq 2$$
This is guaranteed when
$$N \geq k + 1$$
Worst-case reasoning: Assign grades one by one. The first $5$ students could each receive a different grade (one per category). The very next student ($6^{th}$) must repeat a grade.
With $k = 5$:
$$N = k + 1 = 5 + 1 = 6$$
$$\boxed{\text{At most } 6 \text{ gradings guarantee two students with the same grade}}$$
Interpretation of "24 students"
The class has $24$ students, which far exceeds the $6$ required. So the class of $24$ students certainly contains repeated grades. Indeed, distributing $24$ students among $5$ grades:
$$\left\lceil \frac{24}{5} \right\rceil = \lceil 4.8 \rceil = 5$$
So with all $24$ students, at least one grade is shared by at least $5$ students. But to merely guarantee two students with the same grade, grading only $6$ students suffices.
Answer: The maximum number of gradings needed is $6$ (using $k = 5$ grades). The number $24$ simply confirms a repetition is unavoidable.
2080.1 · 5 marks
State generalized Pigeonhole principle. How many ways can we get the 3 digit integers without repeating the digit? [5]
Pigeonhole principle
2080 · 5 marks
What is the pigeonhole principle? Show that binomn+1k=binomnk−1+binomnk\binom{n+1}{k} = \binom{n}{k-1} + \binom{n}{k}binomn+1k=binomnk−1+binomnk where nnn and kkk are positive integers with n≥kn \geq kn≥k . [5]
Permutations
2080 · 5 marks
What is permutation? What is the next permutation in lexicographic order after 362541? [5]
Show solved answerHide answer
Permutation and Next Permutation in Lexicographic Order
Given Data
- Current permutation: 362541 (digits: 3, 6, 2, 5, 4, 1)
- Task: find the next permutation in lexicographic (dictionary) order.
What is a Permutation?
A permutation of a set of elements is an arrangement of those elements in a definite order. For a set of $n$ distinct elements, the total number of permutations is:
$$n! = n \times (n-1) \times (n-2) \times \cdots \times 1$$
Example: For ${1, 2, 3}$, the $3! = 6$ permutations are: $$123,\ 132,\ 213,\ 231,\ 312,\ 321$$
In lexicographic order, permutations are ordered like words in a dictionary, comparing element by element from left to right.
Next Permutation Algorithm
Step 1: Find the largest index $i$ such that $a[i] < a[i+1]$ (the pivot). Step 2: Find the largest index $j > i$ such that $a[j] > a[i]$. Step 3: Swap $a[i]$ and $a[j]$. Step 4: Reverse the suffix starting at $a[i+1]$.
Applying to 362541
Index the digits (0-based):
| Index | 0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|
| Digit | 3 | 6 | 2 | 5 | 4 | 1 |
Step 1: Find pivot (scan right to left):
- $a[4]=4 > a[5]=1$ → no
- $a[3]=5 > a[4]=4$ → no
- $a[2]=2 < a[3]=5$ → pivot found, $i = 2$, value $= 2$
Step 2: Find successor $a[j] > 2$ (scan right to left):
- $a[5]=1 < 2$ → skip
- $a[4]=4 > 2$ → found, $j = 4$
Step 3: Swap $a[2]$ and $a[4]$:
Before: $3,\ 6,\ \mathbf{2},\ 5,\ \mathbf{4},\ 1$ After: $3,\ 6,\ \mathbf{4},\ 5,\ \mathbf{2},\ 1$
Step 4: Reverse suffix from index 3 to end:
Suffix $5, 2, 1 \Rightarrow 1, 2, 5$
Result: $3,\ 6,\ 4,\ 1,\ 2,\ 5$
Result
The next permutation in lexicographic order after 362541 is $\boxed{364125}$.
Verification: $364125 > 362541$ and it is the smallest such permutation (the change occurs at the rightmost possible position with the smallest valid increase), confirming correctness.
0 · 5 marks
Differentiate permutation with combination. What is the next permutation in lexicographic order after 362541? [5]
Inclusion and exclusion principle
2079 · 10 marks
Why do we need principle of inclusion and exclusion? How many ways can we express the four character words ending with a digit and beginning three are lowercase alphabets. Be sure that none of the character can be repeated. Using induction, show that $3^n - 1$ is multiple of 2 for $n \geq 1$. [5+5]
Product rule
2078 · 5 marks
Explain product rule. How many strings are there of four lowercase letters that have the letter x in them? [5]
Make Unit 7 stick
Practice BIT152 with flashcards & quizzes