Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 15-251 Lecture 11 To Exclude Or Not To Exclude? + -

Similar presentations


Presentation on theme: "CS 15-251 Lecture 11 To Exclude Or Not To Exclude? + -"— Presentation transcript:

1

2 CS 15-251 Lecture 11 To Exclude Or Not To Exclude? + -

3 How many integer solutions to the following equations?

4 The coefficient of x k in (1-x) -n = The # of solutions to

5 A famous generating function and power series expansion from calculus:

6 Question: What is the coefficient of X 20 in ?

7 ? The number of integer solutions to:

8 1.A school has 100 students. 50 take French, 40 take Latin, and 20 take both. How many students take neither language? 2.How many positive integers less than 70 are relatively prime to 70? (70=2  5  7) 3.How many 7 card hands have at least one card of each suit?

9 French Latin French AND Latin students: |F  L|=20 |F  L|= F  French students L  Latin students |F|=50 |L|=40 French OR Latin students: Neither language: 100 – 70 = 30 |F|+|L|-|F  L| = 50 + 40 – 20 = 70

10 Lesson: |A  B| = |A| + |B| - |A  B| U  universe of elements A B U

11 2.How many positive integers less than 70 are relatively prime to 70? 70 = 2  5  7 U = [1..70] A 1  integers in U divisible by 2 A 2  integers in U divisible by 5 A 3  integers in U divisible by 7 |A 1 | = 35 |A 2 | = 14 |A 3 |=10 A1A1 A3A3 A2A2 U

12

13 A1A1 A3A3 A2A2 U Lesson: Let S k be the sum of the sizes of All k -tuple intersections of the A i ’s.

14 3.How many 7 card hands contain at least one card of each suit? U  all 7 card hands A 1  all hands with no hearts A 2  all hands with no spades A 3  all hands with no diamonds A 4  all hands with no clubs

15

16 The Principle of Inclusion and Exclusion Let A 1,A 2,…,A n be sets in a universe U. Let S k denote the sum of size of all k -tuple intersections of A i ’s.

17 Let x  A 1   A n be an element appearing in m of the A i ’s. x gets counted times by S 1 “ “ “ times by S 2 “ “ “ times by S 3 “ “ “ times by S n The formula counts x 1 time.

18 Each x in the union gets counted once by the formula so we are done. Immediate corollary:

19 How many different ways can 6 pirates divide 20 bars of gold? # of integral solutions to

20

21

22

23 Question: What is the coefficient of X 20 in ?

24 A famous application of inclusion-exclusion is to calculate the number of DERANGEMENTS. A permutation of [ 1..n ] is called a derangement if for every i, the Number i is not in the i ’th position.

25 Examples: 1 2 3 4 5 4 2 5 3 1 1 2 3 4 5 2 3 1 5 4 23154 is a derangement 42531 is not

26 D n  # of derangements of [1..n] D n = ? D n /n! = ? What is the probability that if n people randomly reach into a dark closet to retrieve their hats, no person will pick their own hat?

27 Calculating D n using Inclusion-Exclusion U = all n! permutations of [ 1..n ] A i = all permutations where i goes in position i # of j -tuples # of permutations with j elements fixed

28

29 But the power series converges rapidly. nearest integer

30 So if we handed back homework in random order the probability that no student would get his/her own paper is about 1/e.

31 How many functions are there from [ 1..k ] to [ 1..n ] ?

32 ONTO(k,n) = # of functions from a k -element set onto an n element set. U = all n k functions from [ 1..k ] to [ 1..n ] A i = functions that miss element i the intersection of j of the A i ’s has (n-j) k functions

33 Lemma: There are n k functions from [ 1..k ] to [ 1..n ]. Each function is constructed by 3 choices: Pick j, 1  j  k Pick j elements from range [ ways to do this] Pick a function from 1..k onto those j elements [ ONTO(k, j) ways to do this]

34


Download ppt "CS 15-251 Lecture 11 To Exclude Or Not To Exclude? + -"

Similar presentations


Ads by Google