main menu main menu (click on the topics below) permutations with some repetitions example...

52
Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Example Example Permutations and Combinations with Repetitions Balls in Boxes Balls in Boxes: Boxes maybe empty Balls in Boxes: Boxes non-empty Click on the picture

Upload: owen-goodman

Post on 24-Dec-2015

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Main Menu Main Menu (Click on the topics below)

Permutations with Some repetitions

Exampler-Combinations with Some repetitions

Example

Example

ExamplePermutations and Combinations with RepetitionsBalls in BoxesBalls in Boxes: Boxes maybe emptyBalls in Boxes: Boxes non-empty

Click on the picture

Page 2: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Permutations and Permutations and Combinations with RepetitionsCombinations with Repetitions

Sanjay Jain, Lecturer, Sanjay Jain, Lecturer,

School of ComputingSchool of Computing

Page 3: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Permutations with Some RepetitionsPermutations with Some Repetitions

Anagrams of MALAYSIA, INDONESIA,…

For example, the different permutations of ABA are:

ABABAAAAB

So our old method doesn’t work.

Page 4: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 5: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Permutations with Some RepetitionsPermutations with Some Repetitions

Theorem: Suppose I have a collection of n objects:

n1 objects of type 1.

n2 objects of type 2.….

nk objects of type k.

Where all the types are distinct, and n1+n2+…+nk=nThen, the number of distinct permutations of the n

objects is

!!....!!

!....*......**

321

11

3

21

2

1

1 kk

k

nnnn

n

n

nnn

n

nnn

n

nn

n

n

Page 6: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 7: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

ProofProof

T1: Place the objects of type 1.

T2: Place the objects of type 2.

T3: Place the objects of type 3.……..

Tk: Place the objects of type k.

1 2 3 n…. ….

Page 8: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

ProofProof

T1: Place the objects of type 1.

T1 can be done in ways.

1n

n

1 2 3 n…. ….

Page 9: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

ProofProof

T2: Place the objects of type 2.

T2 can be done in ways.

2

1

n

nn

1 2 3 n…. ….

Page 10: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

ProofProof

T3: Place the objects of type 3.

T3 can be done in ways.

3

21

n

nnn

1 2 3 n…. ….

Page 11: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

ProofProof

Tk: Place the objects of type k.

Tk can be done in ways.

k

k

n

nnn 11 ....

1 2 3 n…. ….

Page 12: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Permutations with Some RepetitionsPermutations with Some Repetitions

Theorem: Suppose I have a collection of n objects:

n1 objects of type 1.

n2 objects of type 2.….….

nk objects of type k.

k

k

n

nnn

n

nnn

n

nn

n

n 11

3

21

2

1 ....*......**

1

Thus using the multiplication rule, all the n objects can be placed in

ways.

Page 13: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 14: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Permutations with Some RepetitionsPermutations with Some Repetitions

k

k

n

nnn

n

nnn

n

nn

n

n 11

3

21

2

1 ....*......**

1

)!...(!

)!...(*......*

)!(!

)!(*

)!(!

)!(*

)!(!

!

21

121

3212

21

212

1

11 kk

k

nnnnn

nnnn

nnnnn

nnn

nnnn

nn

nnn

n

!!....!!

!

321 knnnn

n

Page 15: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 16: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

ExampleExample

How many anagrams of Malaysia are there?

Answer: M ---1 A ---3 L---1 Y---1 S ---1 I --- 1

!1!1!1!1!3!1

!8

Page 17: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 18: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

r-Combinations with Repetitions allowedr-Combinations with Repetitions allowed

A r-combination, with repetition allowed, chosen from a set X of n elements is an unordered selection of elements taken from X, where repetitions are allowed.

That is we can take several copies of any element of X in the selection.

Page 19: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 20: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Theorem: Theorem:

The number of r-combinations with repetition allowed, that can be selected from a set of size n is

r

nr 1

Page 21: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Proof: Proof:

r X’s and n-1 boundaries.These can be arranged in any order.

The number of ways this can be done is r+n-1Cr .Thus the number of r-combinations with

repetitions allowed is

1st 2nd 3rd nth….

XX X XXX

r

nr 1

Page 22: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 23: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

ExampleExampleI want to buy 5 cans of soft drink. The possible drinks that are available are coke, sprite and

pepsi, where there are unlimited number of each.In how many ways can I choose the 5 cans?

5

135

Using the theorem, this can be done in

ways.

Answer: This is same as the number of 5-combinations, with repetition allowed, from a set of size 3.(since I need to select 5 cans from a set of size 3 with repetition allowed)

Page 24: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 25: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

ExampleExample

Library has budget to buy 20 copies of books on discrete math.

Five different text books on discrete math are available (unlimited number of copies) in the market.

How many ways can the library buy the books?

20

1520

Using the theorem, this can be done in

ways.

Answer: This is same as the number of 20-combinations, with repetition allowed, from a set of size 5.(since I need to select 20 books from a set of size 5 with repetition allowed)

Page 26: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 27: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

ExampleExample

How many integral solutions of equation

x1+x2+x3=20,

where x1,x2,x3 0are there?

20

1320

Using the theorem, this can be done in

ways.

Answer:Note that we can consider each xi as a different type.Choosing xi=r, would mean that we are taking r copies of xi.This is same as the number of 20-combinations, with repetition allowed, from a set of size 3.

Page 28: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 29: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Permutations and Combinations with Permutations and Combinations with RepetitionsRepetitions

Suppose we are choosing k elements from a set of size n. Many problems can be categorized into the following four forms:

k

nk 1Order doesn’t matter and repetitions are allowed:

k

nOrder doesn’t matter and repetitions are not allowed:

Order matters and repetitions are allowed: nk

Order matters and repetitions are not allowed: P(n,k)

Page 30: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 31: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Balls in BoxesBalls in Boxes

Many problems can be formulated as a balls in boxes problem.Suppose we have n balls which are to be placed in m boxes.

Balls are distinguishable or not?Boxes are distinguishable or not?Boxes have limited capacity or infinite capacity?Boxes are required to be non-empty?

Page 32: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Examples:Examples:

Number of functions from X to Y.X has k elements, and Y has r elements.We can consider elements of X as balls, and elements of Y

as boxes. So this problem is same as how many ways we can

distribute k balls in r boxes, where both balls and boxes are distinguishable.

Note that in the above problem we cannot take elements of Y to be balls and elements of X to be boxes:

“ball” goes into only one “box”.A “box” may contain several “balls”.Elements of X may be mapped to only one element of Y.Elements of Y may be an image of several elements of X.

Page 33: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Examples:Examples:

All functions: capacity unlimited.1--1 functions: capacity of boxes is 1.Onto functions: Boxes should be non-empty.Bijective functions: Boxes should be non-empty and

capacity is one.

Page 34: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 35: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Balls in BoxesBalls in Boxes

We will only consider the cases where Boxes are distinguishable. The question when boxes are indistinguishable is hard.

Case I: n distinguishable balls are to be placed in m distinguishable boxes with infinite capacity.

We can divide the job into n tasks.

Ti: place the i-th ball. (i=1 to n)

Ti can be done in m ways (one can select any of the boxes).

Thus using multiplication rule, number of ways to do the job is

mn.

Page 36: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 37: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Balls in BoxesBalls in Boxes

Case II: n indistinguishable balls are to be placed in m distinguishable boxes with infinite capacity.

1st 2nd 3rd mth….

XX X XXX

Choosing n-combination from a set of size m with repetition allowed.

n

mn 1This can be done in ways by the theorem done earlier.

Page 38: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 39: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Balls in BoxesBalls in Boxes

Case III: n distinguishable balls are to be placed in m distinguishable boxes with capacity =1.

m < n 0 ways

m n P(m,n) ways

Page 40: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 41: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Balls in BoxesBalls in Boxes

Case IV: n indistinguishable balls are to be placed in m distinguishable boxes with capacity =1.

m < n 0 ways

m n

n

m

Page 42: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 43: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Balls in Boxes: non-empty boxes.Balls in Boxes: non-empty boxes.

We will only be considering the case of distinguishable boxes and indistinguishable balls.

Case V: n indistinguishable balls are to be placed in m distinguishable boxes, with unlimited capacity such that each box is non-empty.

n<m: 0 ways.n m

Give one ball to each box.

Now distribute the remaining n-m balls in m boxes, without the non-empty constraint.

mn

n

mn

mmn 11

Page 44: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 45: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Balls in Boxes: non-empty boxes.Balls in Boxes: non-empty boxes.

Case VI: n indistinguishable balls are to be placed in m distinguishable boxes, with capacity=1, such that each box is non-empty.

If m = n: 1 way.If m n : 0 ways.

Page 46: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 47: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Balls in Boxes:Balls in Boxes:

We can generalize the technique to several other cases. For example, suppose we want to place 10 indistinguishable balls into 5 distinguishable boxes such that box B1 gets exactly two balls, and each of the remaining boxes get at least one ball.

How many ways can we do it?First place 2 balls in B1, and one ball in each of the other

boxes.Thus we are left with 4 balls, and 4 boxes.(balls: indistinguishable, boxes distinguishable, no other

constraint)

4

144

Page 48: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 49: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Example:Example:

Suppose we want distribute 20 eclairs to 3 children, Tom, Mary and John. Suppose Tom should get atleast 4 eclairs.

In how many ways can we do it?

Note: Children are distinguishable. Eclairs are not.We can first give away 4 eclairs to Tom.Then we can distribute 16 remaining eclairs with no

constraints.

16

1316

Page 50: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT

Page 51: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

Example:Example:

Suppose library wants to buy 20 copies of discrete math book. Suppose there are 5 discrete math text books available in the market.

Suppose there is a constraint that library should buy at least one of each of the text books.

How many ways can the library buy the books?Answer: Different copies of same text books are not

distinguishable. However different text books are distinguishable. We can consider text books as boxes, and the number of copies bought as balls.

Thus we need to distribute 20 indistinguishable balls into 5 distinguishable boxes, with each box being non-empty.

520

120

Page 52: Main Menu Main Menu (Click on the topics below) Permutations with Some repetitions Example r-Combinations with Some repetitions Example Permutations and

END OF SEGMENT