2082 3

BIT152 ยท 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]

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]

Discrete StructureChapter 10: Advanced TopicsRandomized algorithms

Quick answer

Let $S = {a_1, a_2, \ldots, a_{10}}$ be any set of 10 distinct natural numbers chosen from ${1, 2, \ldots, 99}$.

Randomized Algorithms, Pigeonhole Principle Proof, and Generalized Permutations & Combinations


Part 1: Advantages of Randomized Algorithms [2 marks]

  1. Simplicity: Randomized algorithms are often simpler to design and implement than their deterministic counterparts.
  2. Efficiency: They can achieve better average-case time complexity, avoiding worst-case inputs that slow deterministic algorithms.
  3. Avoidance of adversarial inputs: Since the algorithm makes random choices, no fixed input can consistently cause worst-case behavior.
  4. Useful when deterministic solutions are hard: For problems like primality testing, randomized approaches (e.g., Miller-Rabin) are practical and fast.
  5. 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

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

TypeFormula
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.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.