31
1 Discrete Math Basic Permutations and Combinations

1 Discrete Math Basic Permutations and Combinations

Embed Size (px)

Citation preview

Page 1: 1 Discrete Math Basic Permutations and Combinations

1

Discrete Math

Basic Permutations and Combinations

Page 2: 1 Discrete Math Basic Permutations and Combinations

Ordering Distinguishable Objects When we have a group of N objects that

are distinguishable how can we count how many ways we can put M of them into different orders? 20 students are distinguishable, each one is

unique 20 coins of the same type are not

distinguishable, each one is a copy of the others

2

Page 3: 1 Discrete Math Basic Permutations and Combinations

An example Consider 60 students in a classroom. The

students are distinguishable, we can tell one student from another

How many ways to choose an ordered line of 5 students from a class of 60?

Note that order matters 1 2 4 is different from 2 1 4

3

Page 4: 1 Discrete Math Basic Permutations and Combinations

Revisit example: solution Consider the 60 students in the classroom How many ways to choose an ordered row of 5

students from the class?

use product rule 60*59*58*57* 56 = N

OR

N * (55*54*…*1) / (55*54*…*1) = 60! / 55!

4

Page 5: 1 Discrete Math Basic Permutations and Combinations

Another example How many ways can we seat 30 students

in a lecture hall with 80 seats. First student to sit down has 80 choices Second has 79 … 80*79*…*51 * (50*49*….*1)/(50*49*….*1) 80! / 50!

5

Page 6: 1 Discrete Math Basic Permutations and Combinations

Without replacement How many 6 digit numbers are there, in which

no digit is repeated and there are no digits that are 0?

9 choices for first digit (0 not permitted) 8 choices for 2nd digit … 9*8*7*6*5*4 * (3*2*1) / (3 * 2 * 1) 9!/3! We are choosing digits without replacement (we

cannot choose the same digit again)6

Page 7: 1 Discrete Math Basic Permutations and Combinations

With replacement How many 6 digit numbers are there, in which

no digits that are 0? 9 choices for first digit (0 not permitted) 9 choices for 2nd digit … 9*8*7*6*5*4 * (3*2*1) / (3 * 2 * 1) 9!/3! We are choosing digits with replacement (we

can choose the same digit again,)

7

Page 8: 1 Discrete Math Basic Permutations and Combinations

With and without replacement Consider a bag with 10 chips in it, on each chip

one digit (0, 1, …, 9) is written We choose a chip from the bag, the digit on the

chip is the first digit in our number If we are choosing with replacement we put the

chip back in the bag before making our next choice

If we are choosing without replacement we do not put the chip back in the bag before making our next choice

8

Page 9: 1 Discrete Math Basic Permutations and Combinations

Permutation A permutation is a distinct ordering of

distinguishable objects without replacement A k permutation is a distinct ordering of k

objects chosen from N objects where N≥k. Suppose we have N distinguishable objects and

we wish to order k of these objects without replacement. The number of ways we can order these k objects is

9

)!/(!),( kNNkNP

Page 10: 1 Discrete Math Basic Permutations and Combinations

Anagrams An anagram is a permutation of the letters

in a word How many anagrams can we make of a

particular word. First Case: no letters in the word are

repeated Second Case: one or more letters in the

word are repeated10

Page 11: 1 Discrete Math Basic Permutations and Combinations

No repeated letters Try a 4 letter word

For any anagram have 4 choices for the first character Have 3 choices for the second character Have 2 choices for the third character Have 1 choice for the final character

So there are 4! Anagrams of a 4 letter word In general there are N! anagrams of an N

letter word11

Page 12: 1 Discrete Math Basic Permutations and Combinations

With repeated letters (1) When the word has repeated letters we

cannot distinguish the anagrams with those repeated letters in the same locations

Consider the word SPITS The anagram SSITP and SSITP (the two

s’s in different orders) are not distinguishable

12

Page 13: 1 Discrete Math Basic Permutations and Combinations

With repeated letters (2) For a word with one letter appearing twice

SPITS Every distinguishable anagram will have

two S’s. We cannot distinguish if we change the order of those S’s

So 5! /2 possible distinguishable anagrams

13

Page 14: 1 Discrete Math Basic Permutations and Combinations

With repeated letters (3) PINEAPPLE For a letter that repeats 3 times in the word we

have 3*2*1 ways that the P’s can be arranged in each distinguishable anagram

We also have 2 E’s with 2*1 ways to arrange the E’s in each distinguishable anagram

9! / (3! *2!) anagrams

14

Page 15: 1 Discrete Math Basic Permutations and Combinations

Selecting students We used permutations to count how many ways

we could make an orderly row of 5 students from a class of 60 students.

What if our orderly row forms a cluster instead of a row, we no longer have order we have a mob not a line. How many 5 persons mobs can be formed from a class of 60 students.

60 ! / 55! Lines, 5! Possible lines for each mob 60! / (55! * 5!) mobs

15

Page 16: 1 Discrete Math Basic Permutations and Combinations

Selecting students Select a k student mob from a class of N

students. Number of mobs you can select is

Number of ways of choosing k objects from a group of N objects read N choose k

also known as a binomial coefficient

16

),(!)!(

!kNC

k

N

kkN

N

k

N

),( kNC

Page 17: 1 Discrete Math Basic Permutations and Combinations

Combinations Consider the set of N objects from which we are

selecting a group of k objects We are counting the subsets of the set of N

objects that have k elements Each subset of k elements can be considered an

k combination, a subset or unordered group of k elements chosen from the set of N elements

The number of k combinations of the set of N elements is denoted C(N,k)

17

Page 18: 1 Discrete Math Basic Permutations and Combinations

Example: Combinations How many bit strings of length 8 have

exactly 3 1’s? Choose 3 of 8 positions for the 1’s 8 choose 3 ways

OR Choose 5 of 8 positions for the 0’s 8 choose 5 ways 8!/(5!3!)=8*7*6/(2*3) =56

18

Page 19: 1 Discrete Math Basic Permutations and Combinations

Combinations with replacement There are C(n+r-1,r)=C(n+r-1,n-1) r

combinations from a set with n elements when repetition is allowed.

Each r-combination of a set with n elements when repetition is allowed can be represented by a list of n-1 bars (dividers) and r stars (items)

N=4, r=6 one combination **|**|*|*19

Page 20: 1 Discrete Math Basic Permutations and Combinations

Combinations with replacement Each possible combination can be represented by a

list of bars and stars So count the number of ways n-1 bars and r stars

can be arranged in a list The number of ways n-1 bars can be placed into n-

1+r positions

C(n-1+r,n-1) The number of ways r stars can be placed into n-1+r

positions

C(n-1+r,r)20

Page 21: 1 Discrete Math Basic Permutations and Combinations

Combinatorial Proof A combinatorical proof of an identity is a

proof that uses counting arguments to prove that both sides of the identity count the same objects but in different ways

Many identities involving the binomial theorem can be proved using combinatorial proofs

21

Page 22: 1 Discrete Math Basic Permutations and Combinations

The Binomial Theorem

22

nnnn

n

j

jjnn

yn

nxy

n

nyx

nx

n

yxj

nyx

11

0

1...

10

)(

Let x an y be variables, and let n be a nonnegative integer Then

Page 23: 1 Discrete Math Basic Permutations and Combinations

Binomial Theorem Proof The terms in the product are of the form

xn-jyj for j=0,…,n Count the number of terms

Must choose n-j x’s from x terms so the other j terms are y’s

Therefore the coefficient will be n choose n-j

23

Page 24: 1 Discrete Math Basic Permutations and Combinations

Seating students How many ways to seat 30 students in a

lecture hall with 80 seats.

Choose the occupied seats 80 choose 30 Then permute the students in those seats

30! Ways

24

!50

!80!30*

!30!50

!80!30

30

80

Page 25: 1 Discrete Math Basic Permutations and Combinations

Binomial coefficients Let n be a nonnegative integer Then

Combinatorial Proof:

Using the binomial theorem

25

n

k

n

k

n

0

2

n

k

knkn

k

nn

k

n

k

n

00

11)11(2

Page 26: 1 Discrete Math Basic Permutations and Combinations

Why? Binomial Theorem The binomial theorem tells us how to

determine the coefficients in the expansion of (x+y)n

n=0 1 coefficients (1) n=1 x + y coefficients (1,

1) N=2 x2 + 2xy + y2 coefficients (1,2,1)

26

Page 27: 1 Discrete Math Basic Permutations and Combinations

Pascal’s triangleRepresents the binomial coefficients

1 n=0

1 1 n=1

1 2 1 n=2

1 3 3 1 n=3

1 4 6 4 1 n=4

For n=4 x4+4x3y+6x2y2+4xy3+127

Page 28: 1 Discrete Math Basic Permutations and Combinations

Pascal’s triangleCan also be represented

n=0

n=1

n=2

n=3

n=4

28

0

0

0

1

1

1

0

3

0

4

1

4

2

4

3

4

4

4

1

3

3

3

0

2

2

3

1

2

2

2

Page 29: 1 Discrete Math Basic Permutations and Combinations

Pascal’s Identity Pascal’s triangle is based on Pascal’s

identity

Each row is the values of for a given n and for k=0,1, …, n

29

k

n

k

n

k

n

1

1

k

n 1

Page 30: 1 Discrete Math Basic Permutations and Combinations

Proving Pascal’s Identity Combinatorial Proof

Let T be a set containing n+1 elements There are subsets of T with k elements Let S be a subset of T with n elements

S=T-{a} where a is an arbitrary element of T

There are subsets of S with k elements Any subset of T with n elements either contains

element a or does not contain element a

30

k

n 1

k

n

Page 31: 1 Discrete Math Basic Permutations and Combinations

Proving Pascal’s Identity Combinatorial Proof

Any subset of T with k elements either contains element a or does not contain element a S does not contain a so a subset of T with k elements that

does not contain element a is also an subset S. Therefore there are subsets of T with k elements do not contain a

A k element subset of T that does contain a, contains a and k-1 elements of S. There are subsets of S with k-1 elements. Therefore there are k element subsets of T that contain a

Therefore the number of k element subsets of T is

31

1k

n

k

n

1k

n

k

n

k

n

k

n

1

1