<<

MAT230

Discrete

Fall 2019

MAT230 (Discrete Math) Combinatorics Fall 2019 1 / 29 Outline

1 Basic Techniques—The Rule of Products

2

3

4 Permutations and Combinations with Repetition

5 Summary of Combinatorics

6 The Binomial Theorem and Principle of Inclusion-Exclusion

MAT230 (Discrete Math) Combinatorics Fall 2019 2 / 29 There are 256 + 128 = 384 people, so there are 384 different ways to choose a president.

There are 256 ways to choose a president. For each of those ways there are 128 ways to choose a vice president. Thus there are 256 × 128 = 32, 768 ways to choose both.

Basic Counting Techniques

1 How many ways are there to pick a president from a class of 256 women and 128 men?

2 How many ways are there to pick a president from 256 women and a vice president from 128 men?

MAT230 (Discrete Math) Combinatorics Fall 2019 3 / 29 There are 256 ways to choose a president. For each of those ways there are 128 ways to choose a vice president. Thus there are 256 × 128 = 32, 768 ways to choose both.

Basic Counting Techniques

1 How many ways are there to pick a president from a class of 256 women and 128 men? There are 256 + 128 = 384 people, so there are 384 different ways to choose a president.

2 How many ways are there to pick a president from 256 women and a vice president from 128 men?

MAT230 (Discrete Math) Combinatorics Fall 2019 3 / 29 Basic Counting Techniques

1 How many ways are there to pick a president from a class of 256 women and 128 men? There are 256 + 128 = 384 people, so there are 384 different ways to choose a president.

2 How many ways are there to pick a president from 256 women and a vice president from 128 men? There are 256 ways to choose a president. For each of those ways there are 128 ways to choose a vice president. Thus there are 256 × 128 = 32, 768 ways to choose both.

MAT230 (Discrete Math) Combinatorics Fall 2019 3 / 29 Basic Counting Techniques

These problems are examples of counting problems. Our first two counting rules are: 1 The Rule of Sums: If a first task can be done n ways and a second task can be done m ways, and if these tasks cannot be done at the same time, then there are n + m ways to do either task.

2 The Rule of Products: If a first task can be done n ways and a second task can be done m ways, and if the tasks must be done sequentially, then there are n · m ways to do the two tasks.

MAT230 (Discrete Math) Combinatorics Fall 2019 4 / 29 Basic Counting Techniques

The first question we encountered required the Sum Rule because we needed to choose a president and we could do that from the of women (task 1) or from the group of men (task 2). The two tasks could not both be done; we could only do one or the other.

The second question required the Rule of Products because we had to pick a president from the group of women (task 1) and then pick a vice president from the group of men (task 2). The of the tasks is not important, just that each one is independent of the other.

MAT230 (Discrete Math) Combinatorics Fall 2019 5 / 29 If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: bit string:

Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: bit string:

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: 2 bit string:

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: 2 bit string:0

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: 2 2 bit string: 0

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: 2 2 bit string: 01

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: 2 2 2 bit string: 0 1

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: 2 2 2 bit string: 0 11

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: 2 2 2 2 bit string: 0 1 1

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: 2 2 2 2 bit string: 0 1 10

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: 2 2 2 2 2 bit string: 0 1 1 0

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: 2 2 2 2 2 bit string: 0 1 1 01

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 Basic Counting Techniques

Example How many different bit strings having 5 bits are there?

A bit string with 5 bits has five “slots” that can hold bits. To “create” a bit string we need to first choose the first bit, then the second bit, and so on. Thus the product rule will apply here. number of choices: 2 2 2 2 2 bit string: 0 1 1 0 1

If we find the product of all the “number of choices” values we see that there are 32 different bit strings of length 5.

MAT230 (Discrete Math) Combinatorics Fall 2019 6 / 29 In this case we are considering a “digit string” of length 2. This is an example that again calls for the product rule. If we allow zero as the first digit then there are 10 ways to choose the first digit. For each of these there are 10 ways to choose the second digit. So there are 10 × 10 = 100 different two digit base 10 numbers.

If, however, we don’t want to allow zero as leading digit, then there are only 9 ways to choose the first number, but still 10 ways to choose the second number. Thus there are 9 × 10 = 90 different two digit base 10 numbers.

Basic Counting Techniques

Example How many two digit base 10 numbers are there?

MAT230 (Discrete Math) Combinatorics Fall 2019 7 / 29 If, however, we don’t want to allow zero as leading digit, then there are only 9 ways to choose the first number, but still 10 ways to choose the second number. Thus there are 9 × 10 = 90 different two digit base 10 numbers.

Basic Counting Techniques

Example How many two digit base 10 numbers are there?

In this case we are considering a “digit string” of length 2. This is an example that again calls for the product rule. If we allow zero as the first digit then there are 10 ways to choose the first digit. For each of these there are 10 ways to choose the second digit. So there are 10 × 10 = 100 different two digit base 10 numbers.

MAT230 (Discrete Math) Combinatorics Fall 2019 7 / 29 Basic Counting Techniques

Example How many two digit base 10 numbers are there?

In this case we are considering a “digit string” of length 2. This is an example that again calls for the product rule. If we allow zero as the first digit then there are 10 ways to choose the first digit. For each of these there are 10 ways to choose the second digit. So there are 10 × 10 = 100 different two digit base 10 numbers.

If, however, we don’t want to allow zero as leading digit, then there are only 9 ways to choose the first number, but still 10 ways to choose the second number. Thus there are 9 × 10 = 90 different two digit base 10 numbers.

MAT230 (Discrete Math) Combinatorics Fall 2019 7 / 29 There are 26 = 64 bit strings of length 8 beginning with 101 or 010.

This is again a product rule type problem. The best way to think of this is to think of there being 6 choices: Choose one of two prefixes to start the string and then choose each of the 5 remaining bits.

number of choices: 2 2 2 2 2 2 bit string: ········

Basic Counting Techniques

Example How many bit strings of length 8 start with 101 or 010?

MAT230 (Discrete Math) Combinatorics Fall 2019 8 / 29 There are 26 = 64 bit strings of length 8 beginning with 101 or 010.

Basic Counting Techniques

Example How many bit strings of length 8 start with 101 or 010?

This is again a product rule type problem. The best way to think of this is to think of there being 6 choices: Choose one of two prefixes to start the string and then choose each of the 5 remaining bits.

number of choices: 2 2 2 2 2 2 bit string: ········

MAT230 (Discrete Math) Combinatorics Fall 2019 8 / 29 There are 26 = 64 bit strings of length 8 beginning with 101 or 010.

Basic Counting Techniques

Example How many bit strings of length 8 start with 101 or 010?

This is again a product rule type problem. The best way to think of this is to think of there being 6 choices: Choose one of two prefixes to start the string and then choose each of the 5 remaining bits.

number of choices: 2 2 2 2 2 2 bit string: 101 0 1 1 0 1

MAT230 (Discrete Math) Combinatorics Fall 2019 8 / 29 Basic Counting Techniques

Example How many bit strings of length 8 start with 101 or 010?

This is again a product rule type problem. The best way to think of this is to think of there being 6 choices: Choose one of two prefixes to start the string and then choose each of the 5 remaining bits.

number of choices: 2 2 2 2 2 2 bit string: 101 0 1 1 0 1

There are 26 = 64 bit strings of length 8 beginning with 101 or 010.

MAT230 (Discrete Math) Combinatorics Fall 2019 8 / 29 As in the other examples, we have 3 ways to choose the first letter, 26 ways to choose the second. Next we need to pick a digit; there are 10 ways to do this. Finally we have to pick three more letters and have 26 choices for each. Thus we have

3 × 26 × 10 × 26 × 26 × 26 = 13, 709, 280

There are 13,709,280 possible novice class callsigns. (The real allowable number is somewhat less than this as certain three-letter combinations are disallowed).

Basic Counting Techniques

Example U.S. Novice class amateur radio (ham) radio callsigns have two letters, a single digit, and then three more letters. The first letter must be K, N, or W. How many different novice callsigns are there?

MAT230 (Discrete Math) Combinatorics Fall 2019 9 / 29 Basic Counting Techniques

Example U.S. Novice class amateur radio (ham) radio callsigns have two letters, a single digit, and then three more letters. The first letter must be K, N, or W. How many different novice callsigns are there?

As in the other examples, we have 3 ways to choose the first letter, 26 ways to choose the second. Next we need to pick a digit; there are 10 ways to do this. Finally we have to pick three more letters and have 26 choices for each. Thus we have

3 × 26 × 10 × 26 × 26 × 26 = 13, 709, 280

There are 13,709,280 possible novice class callsigns. (The real allowable number is somewhat less than this as certain three-letter combinations are disallowed).

MAT230 (Discrete Math) Combinatorics Fall 2019 9 / 29 There are 4 ways to choose a person to stand at the far left. There are 3 ways to choose the next person, then 2 ways to choose the next, and only 1 way to choose the last person to stand on the right. Thus there are

4 × 3 × 2 × 1 = 4! = 24

ways to arrange four people for a photograph.

Basic Counting Techniques

Example How many ways can four people be arranged in a line for a photograph?

MAT230 (Discrete Math) Combinatorics Fall 2019 10 / 29 Basic Counting Techniques

Example How many ways can four people be arranged in a line for a photograph?

There are 4 ways to choose a person to stand at the far left. There are 3 ways to choose the next person, then 2 ways to choose the next, and only 1 way to choose the last person to stand on the right. Thus there are

4 × 3 × 2 × 1 = 4! = 24

ways to arrange four people for a photograph.

MAT230 (Discrete Math) Combinatorics Fall 2019 10 / 29 As before, there are 4! = 24 ways to arrange the four people. However, the arrangement ABCD is equivalent to the arrangements BCDA, CDAB, and DABC. There are four such “equivalent” arrangements. Thus there are really only 4! = 3! = 6 4 different ways to arrange the four people at the card table.

Basic Counting Techniques

Example How many ways can four people be arranged at a card table?

MAT230 (Discrete Math) Combinatorics Fall 2019 11 / 29 Basic Counting Techniques

Example How many ways can four people be arranged at a card table?

As before, there are 4! = 24 ways to arrange the four people. However, the arrangement ABCD is equivalent to the arrangements BCDA, CDAB, and DABC. There are four such “equivalent” arrangements. Thus there are really only 4! = 3! = 6 4 different ways to arrange the four people at the card table.

MAT230 (Discrete Math) Combinatorics Fall 2019 11 / 29 There are 17 choices for president, but then only 16 choices for vice-president, and finally only 15 choices for secretary. (This assumes that no person can hold two or more offices at the same time). This means that there are 17 × 16 × 15 = 4, 080 different outcomes in the election.

Permutations

How many ways are there to choose a president, vice-president, and secretary from a group of 17 people?

MAT230 (Discrete Math) Combinatorics Fall 2019 12 / 29 Permutations

How many ways are there to choose a president, vice-president, and secretary from a group of 17 people?

There are 17 choices for president, but then only 16 choices for vice-president, and finally only 15 choices for secretary. (This assumes that no person can hold two or more offices at the same time). This means that there are 17 × 16 × 15 = 4, 080 different outcomes in the election.

MAT230 (Discrete Math) Combinatorics Fall 2019 12 / 29 Permutations

Notice that The order of selection matters. The two election outcomes President: Alice President: Bob Vice-President: Bob Vice-President: Mark Secretary: Mark Secretary: Alice represent two different election outcomes even thought the same three people are elected. Repetition is not allowed. We made use of the Rule of Products.

MAT230 (Discrete Math) Combinatorics Fall 2019 13 / 29 Permutations

Definition If n is a positive then n is the product of the first n positive and is denoted n!. Additionally, we define 0! to be 1.

Definition An ordered arrangement of k elements selected from a of n elements, 0 < k ≤ n, where no two elements of the arrangement are the same, is called a of n objects taken k at a time. The total number of such permutations is denoted by P(n, k).

P(n, k) = n(n − 1)(n − 2) ··· (n − k + 1) n! = (n − k)!

MAT230 (Discrete Math) Combinatorics Fall 2019 14 / 29 Answer: Since order matters, and repetition is not allowed, this is a permutation problem. The number of possible outcomes is P(20, 3) = 20 · 19 · 18 = 6, 840.

Question: A group of twenty people have bought tickets for a raffle for free Large Beef from Nick’s Famous Roast Beef. How many possible outcomes are there if three people will each win the prize? Answer: Now order does not matter: Amy, Jessica, and Mike are the same three winners if we list them as Mike, Jessica, and Amy. To count this, we need to compute the number of permutations and then divide by the number of ways the winners can be arranged: Thus, the number of possible outcomes is P(20, 3) 20 · 19 · 18 = = 1, 140. 3! 6

Combinations Question: A group of twenty people are competing in a race. How many possible outcomes are there if prizes are awarded for the first three places?

MAT230 (Discrete Math) Combinatorics Fall 2019 15 / 29 Question: A group of twenty people have bought tickets for a raffle for free Large Beef from Nick’s Famous Roast Beef. How many possible outcomes are there if three people will each win the prize? Answer: Now order does not matter: Amy, Jessica, and Mike are the same three winners if we list them as Mike, Jessica, and Amy. To count this, we need to compute the number of permutations and then divide by the number of ways the winners can be arranged: Thus, the number of possible outcomes is P(20, 3) 20 · 19 · 18 = = 1, 140. 3! 6

Combinations Question: A group of twenty people are competing in a race. How many possible outcomes are there if prizes are awarded for the first three places? Answer: Since order matters, and repetition is not allowed, this is a permutation problem. The number of possible outcomes is P(20, 3) = 20 · 19 · 18 = 6, 840.

MAT230 (Discrete Math) Combinatorics Fall 2019 15 / 29 Answer: Now order does not matter: Amy, Jessica, and Mike are the same three winners if we list them as Mike, Jessica, and Amy. To count this, we need to compute the number of permutations and then divide by the number of ways the winners can be arranged: Thus, the number of possible outcomes is P(20, 3) 20 · 19 · 18 = = 1, 140. 3! 6

Combinations Question: A group of twenty people are competing in a race. How many possible outcomes are there if prizes are awarded for the first three places? Answer: Since order matters, and repetition is not allowed, this is a permutation problem. The number of possible outcomes is P(20, 3) = 20 · 19 · 18 = 6, 840.

Question: A group of twenty people have bought tickets for a raffle for free Large Beef from Nick’s Famous Roast Beef. How many possible outcomes are there if three people will each win the prize?

MAT230 (Discrete Math) Combinatorics Fall 2019 15 / 29 Combinations Question: A group of twenty people are competing in a race. How many possible outcomes are there if prizes are awarded for the first three places? Answer: Since order matters, and repetition is not allowed, this is a permutation problem. The number of possible outcomes is P(20, 3) = 20 · 19 · 18 = 6, 840.

Question: A group of twenty people have bought tickets for a raffle for free Large Beef from Nick’s Famous Roast Beef. How many possible outcomes are there if three people will each win the prize? Answer: Now order does not matter: Amy, Jessica, and Mike are the same three winners if we list them as Mike, Jessica, and Amy. To count this, we need to compute the number of permutations and then divide by the number of ways the winners can be arranged: Thus, the number of possible outcomes is P(20, 3) 20 · 19 · 18 = = 1, 140. 3! 6

MAT230 (Discrete Math) Combinatorics Fall 2019 15 / 29 Combinations The number of combinations of n objects “taken” k at a time is computed as P(n, k) n! C(n, k) = = . k! k!(n − k)!

There are several different notations used for counting combinations and permutations: n Permutations: P(n, k), P(n, k), nPk , Pk n Combinations: C(n, k), C(n, k), C , C n, n k k k

n The last form shown here, k , is often referred to as a binomial coefficient.

n We usually read C(n, k) or k as “n choose k.”

MAT230 (Discrete Math) Combinatorics Fall 2019 16 / 29 Combinations Example How many bit strings of length four have exactly two 1’s and two 0’s? To answer this, consider that there are four locations we need to fill with bits:

.

To get a bit string with two 1’s we first choose two locations to place the 1’s. For example: 1 1. 4! 4·3 There are C(4, 2) = 2!(4−2)! = 2·1 = 6 ways to do this. Now place the 0’s: 0 1 0 1.

There is only C(2, 2) = 1 way to do this. By the Rule of Products, there are C(4, 2) · C(2, 2) = 6 · 1 = 6 bit strings of length four with exactly two 1’s and two 0’s.

MAT230 (Discrete Math) Combinatorics Fall 2019 17 / 29 Answer: We need to choose 2 of the 4 red balls. Since the balls are numbered it makes a difference which two we choose. Also, note that the order the balls are drawn is significant. We need to use a permutation; in this case P(4, 2) = 4 · 3 = 12.

Now suppose that once a ball is selected and the color is observed, it is replaced into the urn before the next selection. How many samples contain two red balls now? 4 · 4 = 16

Theorem The number of k-permutations with repetition of a set of n objects is nk . This is also called an k-.

Permutations when Repetition is Allowed Question: An urn contains 4 numbered red balls and 2 numbered white balls. Balls are drawn sequentially and designated “first” and “second.” How many samples of two balls contain two red balls?

MAT230 (Discrete Math) Combinatorics Fall 2019 18 / 29 Now suppose that once a ball is selected and the color is observed, it is replaced into the urn before the next selection. How many samples contain two red balls now? 4 · 4 = 16

Theorem The number of k-permutations with repetition of a set of n objects is nk . This is also called an k-sequence.

Permutations when Repetition is Allowed Question: An urn contains 4 numbered red balls and 2 numbered white balls. Balls are drawn sequentially and designated “first” and “second.” How many samples of two balls contain two red balls? Answer: We need to choose 2 of the 4 red balls. Since the balls are numbered it makes a difference which two we choose. Also, note that the order the balls are drawn is significant. We need to use a permutation; in this case P(4, 2) = 4 · 3 = 12.

MAT230 (Discrete Math) Combinatorics Fall 2019 18 / 29 Permutations when Repetition is Allowed Question: An urn contains 4 numbered red balls and 2 numbered white balls. Balls are drawn sequentially and designated “first” and “second.” How many samples of two balls contain two red balls? Answer: We need to choose 2 of the 4 red balls. Since the balls are numbered it makes a difference which two we choose. Also, note that the order the balls are drawn is significant. We need to use a permutation; in this case P(4, 2) = 4 · 3 = 12.

Now suppose that once a ball is selected and the color is observed, it is replaced into the urn before the next selection. How many samples contain two red balls now? 4 · 4 = 16

Theorem The number of k-permutations with repetition of a set of n objects is nk . This is also called an k-sequence.

MAT230 (Discrete Math) Combinatorics Fall 2019 18 / 29 In answering this note the following: We can repeatedly choose a particular denomination We can think of the money drawer as list of bills and separators: $100 $50 $20 $10 $5 $1 If we “select” a bill by placing a marker in that denomination’s bin, then the problem at hand reduces to “How many ways can 4 markers and 5 separators be arranged?”

Combinations when Repetition is Allowed

Question: How many ways can four bills from a money drawer with six denominations be selected?

MAT230 (Discrete Math) Combinatorics Fall 2019 19 / 29 Combinations when Repetition is Allowed

Question: How many ways can four bills from a money drawer with six denominations be selected? In answering this note the following: We can repeatedly choose a particular denomination We can think of the money drawer as list of bills and separators: $100 $50 $20 $10 $5 $1 If we “select” a bill by placing a marker in that denomination’s bin, then the problem at hand reduces to “How many ways can 4 markers and 5 separators be arranged?”

MAT230 (Discrete Math) Combinatorics Fall 2019 19 / 29 Combinations when Repetition is Allowed

For example, if we chose two $50 bills, a $10 bill, and a $5 bill the arrangement would look like x x x x $100 $50 $20 $10 $5 $1 Considering only the 5 separators and 4 markers

x x x x

we see there are 9 items and they can be arranged C(9, 4) (or C(9, 5)) different ways. So, there are C(9, 4) = 126 ways to select four bills from a money drawer with six denominations.

MAT230 (Discrete Math) Combinatorics Fall 2019 20 / 29 There is one way to pick one cookie of each type. This leaves 3 cookies to pick. 1 · C(9 + 3 − 1, 3) = 165 ways.

C(9 + 12 − 1, 12) = 125, 970 ways. a dozen cookies with at least one of each type?

Combinations when Repetition is Allowed

Theorem There are C(n + k − 1, k) k-combinations with repetition from the set with n elements. These are also called k-collections.

Notice that C(n + k − 1, k) = C(n − 1 + k, n − 1), an alternative form sometimes used. Example: A cookie shop has 9 varieties of cookies. How many different ways are there to select a dozen cookies?

MAT230 (Discrete Math) Combinatorics Fall 2019 21 / 29 There is one way to pick one cookie of each type. This leaves 3 cookies to pick. 1 · C(9 + 3 − 1, 3) = 165 ways.

a dozen cookies with at least one of each type?

Combinations when Repetition is Allowed

Theorem There are C(n + k − 1, k) k-combinations with repetition from the set with n elements. These are also called k-collections.

Notice that C(n + k − 1, k) = C(n − 1 + k, n − 1), an alternative form sometimes used. Example: A cookie shop has 9 varieties of cookies. How many different ways are there to select a dozen cookies? C(9 + 12 − 1, 12) = 125, 970 ways.

MAT230 (Discrete Math) Combinatorics Fall 2019 21 / 29 There is one way to pick one cookie of each type. This leaves 3 cookies to pick. 1 · C(9 + 3 − 1, 3) = 165 ways.

Combinations when Repetition is Allowed

Theorem There are C(n + k − 1, k) k-combinations with repetition from the set with n elements. These are also called k-collections.

Notice that C(n + k − 1, k) = C(n − 1 + k, n − 1), an alternative form sometimes used. Example: A cookie shop has 9 varieties of cookies. How many different ways are there to select a dozen cookies? C(9 + 12 − 1, 12) = 125, 970 ways. a dozen cookies with at least one of each type?

MAT230 (Discrete Math) Combinatorics Fall 2019 21 / 29 Combinations when Repetition is Allowed

Theorem There are C(n + k − 1, k) k-combinations with repetition from the set with n elements. These are also called k-collections.

Notice that C(n + k − 1, k) = C(n − 1 + k, n − 1), an alternative form sometimes used. Example: A cookie shop has 9 varieties of cookies. How many different ways are there to select a dozen cookies? C(9 + 12 − 1, 12) = 125, 970 ways. a dozen cookies with at least one of each type? There is one way to pick one cookie of each type. This leaves 3 cookies to pick. 1 · C(9 + 3 − 1, 3) = 165 ways.

MAT230 (Discrete Math) Combinatorics Fall 2019 21 / 29 Summary of Combinatoric Formulas

Suppose there is a set with n elements from which we need to select k elements. The following table summarizes the formulas needed to compute the number of ways the selection can be made.

Does order matter? yes no Is Ordered list Unordered list yes repetition nk C(n + k − 1, k) allowed? Permutation Set no P(n, k) C(n, k)

MAT230 (Discrete Math) Combinatorics Fall 2019 22 / 29 The Binomial Theorem The expression (x + y) is called a binomial since it consists of two terms. Theorem (Binomial Theorem) If n ≥ 0, then, for expressions x and y,

n X n (x + y)n = xn−k y k k k=0 n n  n  n = xny 0 + xn−1y 1 + ··· + x1y n−1 + x0y n 0 1 n − 1 n

Example

3 3 3 3 (5 + 2a)3 = 53(2a)0 + 52(2a)1 + 51(2a)2 + 50(2a)3 0 1 2 3 = 1 · 125 · 1 + 3 · 25 · 2a + 3 · 5 · 4a2 + 1 · 1 · 8a3 = 125 + 150a + 60a2 + 8a3

MAT230 (Discrete Math) Combinatorics Fall 2019 23 / 29 Binomial Coefficients and Pascal’s Triangle

1 One way to generate the binomial coefficients is with 1 1 Pascal’s Triangle. 1 2 1 Notice how each entry in the triangle is the sum of the two 1 3 3 1 elements above it.

This relationship is described 1 4 6 4 1 by Pascal’s Identity: 1 5 10 10 5 1 n n − 1 n − 1 = + . k k − 1 k 1 6 15 20 15 6 1 \/ 1 7 21 35 35 21 7 1

MAT230 (Discrete Math) Combinatorics Fall 2019 24 / 29 Pascal’s Identity Theorem Let n and k be positive integers with n > k. Then

C(n, k) = C(n − 1, k − 1) + C(n − 1, k).

Proof. Let A be a set with |A| = n. Pick any one element of A and label it x, leaving the remaining n − 1 elements of A unlabeled. Now choose k elements of A to form a subset S. There are two cases: 1 x ∈ S: There are C(n − 1, k − 1) ways the remaining k − 1 elements of S could have been chosen from the n − 1 unlabeled elements of A. 2 x ∈/ S: All k elements of S must have been chosen from the n − 1 unlabeled elements of A. There are C(n − 1, k) ways to do this. Since one or the the other of these cases must occur, their sum must equal C(n, k), the number of ways to form a subset with k elements from a set with n elements. Thus C(n, k) = C(n − 1, k − 1) + C(n − 1, k).

MAT230 (Discrete Math) Combinatorics Fall 2019 25 / 29 Partitions

Recall that a A is a collection of disjoint, nonempty subsets of A that have A as their union. Our current text focuses this a bit more, saying that a partition of a set A is a set of one or more nonempty subsets of A that have A as their union. Example Suppose A = {a, b, c}. The following are all partitions of A: {{a}, {b}, {c}} {{a, b}, {c}} {{a, b, c}}.

MAT230 (Discrete Math) Combinatorics Fall 2019 26 / 29 Basic Law of Addition Definition The Basic Law of Addition says that if A is a finite set and if {A1, A2,..., An} is a partition of A, then

n X |A| = |Ak | k=1

= |A1| + |A2| + ··· + |An|

= |A1 ∪ A2 ∪ · · · ∪ An|.

Example Think back to when you were learning to count and do basic math in elementary school. The numbers 3 and 5 might have been represented by a group of three blocks and a group of five blocks. Adding 3 + 5 meant counting the number of blocks in both groups.

MAT230 (Discrete Math) Combinatorics Fall 2019 27 / 29 Adding |A1| and |A2| won’t work because we count elements that are common to both sets twice. However, since we count them exactly twice, we can correct for this by subtracting the number of elements common to both sets.

The Principle of Inclusion-Exclusion for any two finite sets A1 and A2 says |A1 ∪ A2| = |A1| + |A2| − |A1 ∩ A2|.

Inclusion-Exclusion

Note that |A1 ∪ A2| = |A1| + |A2|

when A1 and A2 are disjoint. What if they are not disjoint? How can we compute |A1 ∪ A2|?

MAT230 (Discrete Math) Combinatorics Fall 2019 28 / 29 The Principle of Inclusion-Exclusion for any two finite sets A1 and A2 says |A1 ∪ A2| = |A1| + |A2| − |A1 ∩ A2|.

Inclusion-Exclusion

Note that |A1 ∪ A2| = |A1| + |A2|

when A1 and A2 are disjoint. What if they are not disjoint? How can we compute |A1 ∪ A2|?

Adding |A1| and |A2| won’t work because we count elements that are common to both sets twice. However, since we count them exactly twice, we can correct for this by subtracting the number of elements common to both sets.

MAT230 (Discrete Math) Combinatorics Fall 2019 28 / 29 Inclusion-Exclusion

Note that |A1 ∪ A2| = |A1| + |A2|

when A1 and A2 are disjoint. What if they are not disjoint? How can we compute |A1 ∪ A2|?

Adding |A1| and |A2| won’t work because we count elements that are common to both sets twice. However, since we count them exactly twice, we can correct for this by subtracting the number of elements common to both sets.

The Principle of Inclusion-Exclusion for any two finite sets A1 and A2 says |A1 ∪ A2| = |A1| + |A2| − |A1 ∩ A2|.

MAT230 (Discrete Math) Combinatorics Fall 2019 28 / 29 |D ∪ S| = |D| + |S| − |D ∩ S|

Inclusion-Exclusion

Example Consider the set of students in our class. 1 Let all students who like Dunkin Donuts coffee belong to set D. |D| = ? 2 Let all students who like Starbucks coffee belong to set S. |S| = ? 3 How many of the students in our class like both Dunkin Donuts coffee and Starbucks coffee? 4 How many students students like Dunkin Donuts coffee or Starbucks coffee?

MAT230 (Discrete Math) Combinatorics Fall 2019 29 / 29 Inclusion-Exclusion

Example Consider the set of students in our class. 1 Let all students who like Dunkin Donuts coffee belong to set D. |D| = ? 2 Let all students who like Starbucks coffee belong to set S. |S| = ? 3 How many of the students in our class like both Dunkin Donuts coffee and Starbucks coffee? 4 How many students students like Dunkin Donuts coffee or Starbucks coffee?

|D ∪ S| = |D| + |S| − |D ∩ S|

MAT230 (Discrete Math) Combinatorics Fall 2019 29 / 29