Presentation is loading. Please wait.

Presentation is loading. Please wait.

Applications of Inclusion-Exclusion: Selected Exercises.

Similar presentations


Presentation on theme: "Applications of Inclusion-Exclusion: Selected Exercises."— Presentation transcript:

1 Applications of Inclusion-Exclusion: Selected Exercises

2 2 8 How many onto functions are there from a set with 7 elements to a set with 5 elements? Equivalently, how many ways are there to assign 7 tasks to 5 computers such that each computer gets ≥ 1 task?

3 3 8 Solution Let the domain D = { a, b, c, d, e, f, g }. Let the co-domain C = { 1, 2, 3, 4, 5 }. Let a function f: D  C have property P 1 when element f(x) = 1, for some x  D. P 2 when element f(x) = 2, for some x  D. P 3 when element f(x) = 3, for some x  D. P 4 when element f(x) = 4, for some x  D. P 5 when element f(x) = 5, for some x  D. We count all functions that have P 1, P 2, …, and P 5.

4 4 8 Solution continued Let A 1 be the set of functions that do not have P 1. A 2 be the set of functions that do not have P 2. A 3 be the set of functions that do not have P 3. A 4 be the set of functions that do not have P 4. A 5 be the set of functions that do not have P 5. The set of desired functions is U – ( A 1  A 2  A 3  A 4  A 5 ).

5 5 8 Solution continued |U| = 5 7. |A i | = 4 7, for 1  i  5. |A i  A j | = 3 7, for 1  i < j  5. |A i  A j  A k | = 2 7, for 1  i < j < k  5. |A i  A j  A k  A l | = 1 7, for 1  i < j < k < l  5. The overall answer is 5 7 – C(5,1)4 7 + C(5,2)3 7 - C(5,3)2 7 + C(5,4)1 7.

6 10 6 In how many ways can 8 distinct balls be distributed into 3 distinct urns if each urn must contain ≥ 1 ball?

7 7 10 Solution Let property: P 1 be a distribution of the balls such that urn 1 has ≥ 1 ball. P 2 be a distribution of the balls such that urn 2 has ≥ 1 ball. P 3 be a distribution of the balls such that urn 3 has ≥ 1 ball. Let set: A 1 be the set of distributions that do not have P 1. A 2 be the set of distributions that do not have P 2. A 3 be the set of distributions that do not have P 3. Then, we want |U| - | A 1  A 2  A 3 | = |U| - | A 1 | - | A 2 | - | A 3 | + | A 1  A 2 | + | A 1  A 3 | + | A 2  A 3 | - | A 1  A 2  A 3 |.

8 8 10 Solution continue |U| = the # of distributions of the 8 distinct balls into the 3 distinct urns = 3 8. (Each ball can go into 3 possible urns.) | A 1 | = | A 2 | = | A 3 | = 2 8. | A 1  A 2 | = | A 1  A 3 | = | A 2  A 3 | = 1 8. | A 1  A 2  A 3 | = 0 8. The answer is x x1 8.

9 The Hatcheck Problem n people check their hat at Woodstocks How many ways can the n hats be returned so that person i does not get his/her own hat? D n : The number of permutations of 1, 2, …, n, where i is not fixed by the permutation, 1  i  n. D 3 =

10 10 Let P i be the set of permutations where i is fixed (is permuted to position i). D n = | U – ( P 1  P 2  …  P n ) |. | U | = n! For | P 1  P 2  …  P n |, use inclusion-exclusion:

11 11Copyright © Peter Cappello The Principle of Inclusion-Exclusion | P 1  P 2 ...  P n | = Σ | P i | - Σ | P i  P j | + Σ | P i  P j  P k | (-1) n-1 Σ | P 1  P 2 ...  P n | | P 1  P 2 ...  P n | = C(n,1)(n – 1)! - C(n, 2)(n – 2)! + C(n, 3)(n – 3)! (-1) n-1 C(n,n)(n – n)!

12 12 | P 1  P 2 ...  P n | = C(n,1)(n – 1)! - C(n, 2)(n – 2)! + C(n, 3)(n – 3)! (-1) n-1 C(n,n)(n – n)! | P 1  P 2 ...  P n | = n!/1! - n!/2! + n!/3! (-1) n-1 n!/n!

13 | P 1  P 2 ...  P n | = n!/1! - n!/2! + n!/3! (-1) n-1 n!/n! = n! (1/1! - 1/2! + 1/3! (-1) n-1 1/n! ) We want D n = | U – ( P 1  P 2  …  P n ) | = n! - n! (1/1! - 1/2! + 1/3! (-1) n-1 1/n! ) = n! ( 1 - 1/1! - 1/2! + 1/3! (-1) n-1 1/n! ) Sidebar: Probability that nobody gets their hat (assuming each permutation is equally likely) is D n / n! = 1 - 1/1! - 1/2! + 1/3! (-1) n-1 1/n! This converges quickly to e -1 since e -1 = Σ n=0,  (-1) n / n! 13

14 END! 14

15 15 Characters   . ≥ ≡ ~ ┌ ┐ └ ┘        ≈      Ω Θ     Σ ¢        

16 16 *18 Use a combinatorial argument to show that the sequence { D n }, where D n denotes the # of derangements of n objects, satisfies the recurrence D n = (n – 1)(D n-1 + D n-2 ), for n ≥ 2. Hint: There are n – 1 choices for the 1 st element k of a derangement. Consider separately the derangements that start with k that do and do not have 1 in the k th position.

17 17 *18 Solution Use the Product Rule to count the derangements in 2 steps: Step 1: Choose the number permuted to position 1: There are n – 1 ways to do that (it cannot be 1). Step 2, Complete the derangement: Let the number permuted to position 1 be i  1. Use the Sum Rule: Partition this set of derangements into: Those with position i = 1 : There are D n-2 ways to complete the derangement. Those with position i  1: Think of element 1 temporarily renamed i. Elements 2, 3, …, n are to be deranged (1 cannot go in position i) There are D n-1 ways to derange them. Thus, D n = (n – 1)(D n-2 + D n-1 ), where D 0 = D 1 = 0.


Download ppt "Applications of Inclusion-Exclusion: Selected Exercises."

Similar presentations


Ads by Google