Discrete Structure · Unit 10
Advanced Topics
Exam-focused notes for Advanced Topics (Discrete Structure, BIT152): what the TU syllabus asks and how it has actually been tested, with 2 solved past questions from this unit.
Advanced Topics in short
This chapter joins earlier ideas to real computing. It covers matrices of 0s and 1s, algorithms that use random choices, and arithmetic with very large numbers. It ends with uses of modular arithmetic.
What this unit covers
- Boolean matrices and operations
- Randomized algorithms
- Computer arithmetic with large integers
- Modular arithmetic applications
Randomized algorithms
2082 · 10 marks
List some advantages of randomized algorithm.Given any set of ten natural numbers between 1 and 99 inclusive, prove that there are two disjoint nonempty subsets of the set with equal sums of their elements.How do you generalize permutations and combinations?[2+4+4]
Show solved answerHide answer
Randomized Algorithms, Pigeonhole Principle Proof, and Generalized Permutations & Combinations
Part 1: Advantages of Randomized Algorithms [2 marks]
- Simplicity: Randomized algorithms are often simpler to design and implement than their deterministic counterparts.
- Efficiency: They can achieve better average-case time complexity, avoiding worst-case inputs that slow deterministic algorithms.
- Avoidance of adversarial inputs: Since the algorithm makes random choices, no fixed input can consistently cause worst-case behavior.
- Useful when deterministic solutions are hard: For problems like primality testing, randomized approaches (e.g., Miller-Rabin) are practical and fast.
- Space efficiency: Some randomized algorithms use less memory than deterministic equivalents.
Part 2: Prove that among any 10 natural numbers from {1, ..., 99}, there exist two disjoint nonempty subsets with equal sums [4 marks]
Setup
Let $S = {a_1, a_2, \ldots, a_{10}}$ be any set of 10 distinct natural numbers chosen from ${1, 2, \ldots, 99}$.
Step 1: Count the nonempty subsets
The number of nonempty subsets of $S$ is: $$2^{10} - 1 = 1023$$
Step 2: Bound the possible sums
The maximum possible sum of any nonempty subset is at most: $$99 + 98 + 97 + 96 + 95 + 94 + 93 + 92 + 91 + 90 = 945$$
The minimum possible sum of any nonempty subset is at least $1$.
So every nonempty subset has a sum in the range ${1, 2, \ldots, 945}$, giving at most 945 distinct sum values.
Step 3: Apply the Pigeonhole Principle
We have:
- 1023 nonempty subsets (pigeons)
- 945 possible sum values (holes)
Since $1023 > 945$, by the Pigeonhole Principle, there exist at least two distinct nonempty subsets $A$ and $B$ of $S$ such that: $$\text{sum}(A) = \text{sum}(B)$$
Step 4: Make the subsets disjoint
If $A$ and $B$ are already disjoint, we are done.
If $A$ and $B$ share common elements, let $C = A \cap B$. Define: $$A' = A \setminus C, \quad B' = B \setminus C$$
Then:
- $A'$ and $B'$ are disjoint (by construction).
- Since $A \neq B$, at least one of $A'$, $B'$ is nonempty; in fact both are nonempty (if one were empty, say $A' = \emptyset$, then $A \subseteq B$, and $\text{sum}(A) = \text{sum}(B)$ would force $\text{sum}(B \setminus A) = 0$, impossible for natural numbers).
- Their sums are equal: $$\text{sum}(A') = \text{sum}(A) - \text{sum}(C) = \text{sum}(B) - \text{sum}(C) = \text{sum}(B')$$
Therefore, $A'$ and $B'$ are two disjoint nonempty subsets of $S$ with equal sums. $\blacksquare$
Part 3: Generalization of Permutations and Combinations [4 marks]
Permutations with Repetition (Generalized Permutations)
When repetition is allowed, the number of ways to arrange $r$ objects chosen from $n$ distinct types is: $$n^r$$
When objects are not all distinct (multiset permutations): If we have $n$ objects where object type $i$ appears $n_i$ times (with $n_1 + n_2 + \cdots + n_k = n$), the number of distinct arrangements is: $$\frac{n!}{n_1!, n_2!, \cdots, n_k!}$$
Example: The number of arrangements of the letters in "MISSISSIPPI": $\frac{11!}{1!,4!,4!,2!} = 34650$
Combinations with Repetition (Generalized Combinations)
When repetition is allowed (multiset combinations): The number of ways to choose $r$ objects from $n$ types with repetition allowed (order does not matter) is: $$\binom{n + r - 1}{r} = \binom{n+r-1}{n-1}$$
Example: Choosing 3 scoops of ice cream from 5 flavors (repetition allowed): $\binom{5+3-1}{3} = \binom{7}{3} = 35$
Summary Table
| Type | Formula |
|---|---|
| Permutation without repetition ($n$ distinct, choose $r$) | $P(n,r) = \dfrac{n!}{(n-r)!}$ |
| Permutation with repetition | $n^r$ |
| Multiset permutation | $\dfrac{n!}{n_1!, n_2!, \cdots, n_k!}$ |
| Combination without repetition | $C(n,r) = \dfrac{n!}{r!(n-r)!}$ |
| Combination with repetition | $\dbinom{n+r-1}{r}$ |
These generalizations extend the basic counting principles to handle real-world scenarios where items may repeat or be indistinguishable.
Boolean matrices and operations
2080.1 · 10 marks
What is Boolean matrix and list its operations?Prove that the sum of first NNN odd integers is N2N^2N2 using mathematical induction.[4+6]
Make Unit 10 stick
Practice BIT152 with flashcards & quizzes