section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight...

34
Section 2.3 183 Combinatorics 183 Section 2. Section 2. Section 2. Section 2.3 Combinatorics Combinatorics Combinatorics Combinatorics Purpose of Section Purpose of Section Purpose of Section Purpose of Section To introduce some basic tools of counting, such as the multiplication principle, permutations and combinations. Introduction Introduction Introduction Introduction Someone once said every mathematician is part combinatorist since combinatorial ideas pervade every area of mathematics, pure and applied. Today, the interest in combinatorial analysis is fueled by important problems in chemistry, biology, physics and computer science. Problems in chemistry arise in studying the arrangement of atoms in molecules and crystals, in physics in the study of statistical and quantum mechanics, in biology in studying gene structure, and in computer science in a myriad of problems ranging from computer networks to microcircuit design. Combinatorics is a branch of mathematics that deals with concrete, easy to understand problems and often requires no technical knowledge. However, simply because a problem is easy to understand, that doesn’t imply it is easy to solve. For example, given an ordinary 8 8 × checkerboard, how many ways can you cover it with dominoes (each domino covering 2 adjacent squares)? Although the problem is easy to understand, it is not easy to solve. The total number of different “coverings” was not solved until 1961 by M.E. Fischer, who found the number to be ( ) 2 4 2 901 12,988,816 = . Although it is difficult to define such a multifaceted subject as combinatorics combinatorics combinatorics combinatorics, it is simply the subject of counting. Counting is so commonplace, we generally don’t give it much thought, yet as the reader will see, the techniques of counting are as ingenious as any in abstract mathematics, and just as difficult. More than one good mathematician has been embarrassed by a seemingly simply “counting” problem. Multiplication Principle Multiplication Principle Multiplication Principle Multiplication Principle One of the most basic principles of counting, if not the most basic, is the multiplication principle multiplication principle multiplication principle multiplication principle. Although the principle is simple, it has far reaching consequences. For example, how many dots are there in the array of dots in Figure 1?

Upload: doanbao

Post on 21-Jul-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 183 Combinatorics

183

Section 2.Section 2.Section 2.Section 2.3333 Combinatorics Combinatorics Combinatorics Combinatorics

Purpose of SectionPurpose of SectionPurpose of SectionPurpose of Section To introduce some basic tools of counting, such as the

multiplication principle, permutations and combinations.

Introduction Introduction Introduction Introduction

Someone once said every mathematician is part combinatorist since

combinatorial ideas pervade every area of mathematics, pure and applied.

Today, the interest in combinatorial analysis is fueled by important problems

in chemistry, biology, physics and computer science. Problems in chemistry

arise in studying the arrangement of atoms in molecules and crystals, in

physics in the study of statistical and quantum mechanics, in biology in

studying gene structure, and in computer science in a myriad of problems

ranging from computer networks to microcircuit design.

Combinatorics is a branch of mathematics that deals with concrete, easy

to understand problems and often requires no technical knowledge. However,

simply because a problem is easy to understand, that doesn’t imply it is easy

to solve. For example, given an ordinary 8 8× checkerboard, how many ways

can you cover it with dominoes (each domino covering 2 adjacent squares)?

Although the problem is easy to understand, it is not easy to solve. The total

number of different “coverings” was not solved until 1961 by M.E. Fischer,

who found the number to be ( )24

2 901 12,988,816⋅ = .

Although it is difficult to define such a multifaceted subject as

combinatoricscombinatoricscombinatoricscombinatorics, it is simply the subject of counting. Counting is so

commonplace, we generally don’t give it much thought, yet as the reader will

see, the techniques of counting are as ingenious as any in abstract

mathematics, and just as difficult. More than one good mathematician has

been embarrassed by a seemingly simply “counting” problem.

Multiplication PrincipleMultiplication PrincipleMultiplication PrincipleMultiplication Principle

One of the most basic principles of counting, if not the most basic, is the

multiplication principlemultiplication principlemultiplication principlemultiplication principle. Although the principle is simple, it has far reaching

consequences. For example, how many dots are there in the array of dots in

Figure 1?

Page 2: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 184 Combinatorics

184

Count the Dots

Figure 1

Your answer is 30 and we suspect you arrived at this by counting 10 dots in

the first row and then multiplied by 3. If this is true, then you used the

multiplication principle. As a small step up in complexity chain, try counting

the number of different paths from A to C in Figure 2. No doubt this problem

didn’t stump you either, getting 4 5 20⋅ = paths. Again, you used the

multiplication principle.

How Many Paths from A to C?

Figure 2

This leads us to the formal statement of the multiplication principle.

Multiplication RuleMultiplication RuleMultiplication RuleMultiplication Rule: If a procedure can be broken into successive stages, and if

there are 1s outcomes for the first stage, 2s outcomes for the second stage, …,

and n

s for the n th stage, then the entire procedure has 1 2...,n

s s s outcomes. .

Example Example Example Example 1 1 1 1 ((((CountingCountingCountingCounting SubsetsSubsetsSubsetsSubsets)))) Show that that a set { }1 2, ,...,n

A a a a=

containing n elements has 2n subsets.

Proof:Proof:Proof:Proof: A subset of A can be formed in n successive steps. On the first step,

one can pick or not pick 1a , on the second step one can pick or not pick 2a , …

and so on. On each step there are two options, to pick or not to pick. Using

the multiplication principle, the number of subsets that can be selected is

Page 3: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 185 Combinatorics

185

2 2 2 2n⋅ ⋅ ⋅⋅ =

Example 2: Example 2: Example 2: Example 2: ((((Counting FunctionsCounting FunctionsCounting FunctionsCounting Functions1111)))) How many functions are there from the set

{ }, ,A a b c= to the set of binary numbers { }0,1B = ?

Solution Solution Solution Solution For each of the 3 values in A the function can take on 2 values.

Hence, by the multiplication rule the number of functions is 32 2 2 2 8⋅ ⋅ = = . We

leave it to the reader to draw graphs of the eight functions. In general the

number of functions from a set with cardinality n to a set with cardinality m

is nm .

Although the multiplication principle is very simple, it has far reaching

results. One is the study of permutations.

PermutationsPermutationsPermutationsPermutations

A permupermupermupermutationtationtationtation is simply an arrangementarrangementarrangementarrangement of objects. For example the

permutations of the three letters abc are the six arrangements

, , , , ,abc acb bac bca cab cba

The number of permutations increases dramatically as the size of the set

increases. The number of permutations of the first 10 letters of the alphabet

abcdefghij is 3,628,800 . We certainly didn’t arrive at that number by listing each

arrangement. We simply argue that we can select the left-most member in our

arrangement 10 ways, and once this is done there are 9 choices for the second

member in the arrangement, the third member 8 ways, … and so down to the last

member. Then, using the multiplication principle, we find the number of

permutations or arrangements of 10 objects to be 10 factorial, or

10 10 9 8 7 6 5 4 3 2 1 3 628 800! , ,= ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ = .

Now, suppose four individuals , , ,a b c d are in a foot race and we wish to

determine the possible ways the runners can finish first and second. Each of the

four runners can finish first, and for each winner, there are 3 second-place

finishers. Hence by the multiplication principle there are 4 3 12⋅ = possible ways

the runners can finish first and second, which are.

1 We will talk more about functions in Chapter 4.

Page 4: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 186 Combinatorics

186

Permutations of Two Elements from a Set of Four Elements

Figure 3

This leads to the general definition of permutations of different sizes.

Big NumberBig NumberBig NumberBig Number:::: Factorials grow very fast. The number 50! is thirty vigintillion, four hundred and four novemdecillion, ninety three octodecillion, two hundred and one septendecillion, seven hundred and thirteen sexdecillion, three hundred and seventy eight quindecillion, forty three quatuordecillion, six hundred and twelve tredecillion, six hundred and eight dodecillion, one hundred and sixty six undecillion, sixty four decillion, seven hundred and sixty eight nonillion, eight hundred and forty four octillion, three hundred and seventy seven septillion, six hundred and forty one sextillion, five hundred and sixty eight quintillion, nine hundred and sixty quadrillion, five hundred and twelve trillion. That is

50 30414093201713378043612608166064768844377641568960512000000000000!=

Definition: Definition: Definition: Definition: A permutation permutation permutation permutation of r elements taken from a set of n elements is

simply an arrangement of r elements chosen from a set of n elements. The

number of such arrangements (or permutations) is denoted by ( ),P n r .

Using the multiplication principle, we find the number of permutations.

Theorem 1 Number of Theorem 1 Number of Theorem 1 Number of Theorem 1 Number of Permutations Permutations Permutations Permutations

The number of permutations of r elements taken from a set of size n is

Page 5: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 187 Combinatorics

187

( )( )

( ) ( ) ( )!

, 1 2 1!

nP n r n n n n r

n r= = ⋅ − ⋅ − − +

−�

Proof:Proof:Proof:Proof:

Choosing r elements from a set of size n , we have

▶ the first element can be selected n ways.

▶ the second element can be selected 1n − ways (since now

There are 1n − left).

▶ the third element can be selected 2n − ways (since

now there are 2n − left).

… … … … … … … … … … … …

▶ the thr element can be selected 1n r− + ways

Hence, by the principle of sequential counting (or the multiplication

rule), we have

( ) ( ) ( ) ( ) factors

, 1 2 1

r

P n r n n n n r= ⋅ − ⋅ − − +��������������

.

▶ When r n= we have the number of permutations of n objects to be

n factorial, or

( ) ( )( ) ( )( )1 2 2 1, !P n n n n n n= − − =�

Example Example Example Example 3333 Permutations Permutations Permutations Permutations of of of of a Set a Set a Set a Set with 3 Elements with 3 Elements with 3 Elements with 3 Elements

Find the permutations of 1, 2 and 3r = elements selected from { }, ,a b c .

SolutionSolutionSolutionSolution

The underlying set { }, ,a b c has 3n = elements. The permutations of 1,

2 and 3 elements from { }, ,a b c are listed in Table 1.

1r = 2r = 3r =

a ab abc

b ac acb

c ba bac

bc bca

Page 6: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 188 Combinatorics

188

ca cab

cb cba

Permutations ( ),P n r

Table 1

We don’t use set notation for writing permutations2 since order is important.

The permutation ab is not the same as ba .

Margin Note:Margin Note:Margin Note:Margin Note: Permutations: Order matters.

Margin Note:Margin Note:Margin Note:Margin Note: To evaluate ( ),P n r start at n and multiply r factors.

( )

( )

( )

( )

( )

4, 2 4 3 12

7,3 7 6 5 210

4,1 4 4

10,3 10 9 8 720

4, 4 4 3 2 1 24

P

P

P

P

P

= ⋅ =

= ⋅ ⋅ =

= =

= ⋅ ⋅ =

= ⋅ ⋅ ⋅ =

Example Example Example Example 4444

How many ways can one arrange the seven letters of the word SYSTEM?

Solution Solution Solution Solution

The two S’s in SYSTEM are indistinguishable3 so we must modify our

argument. If we momentarily call the two S’s as 1S and 2S , then we have

1 2S YS TEM , which has 6! permutations. But the two letters 1S and 2S can be

arranged 2! 2= ways, so we must divide 6! by 2!, getting the number of

distinguishable (permutations you can recognize with the naked eye)

permutations of SYSTEM to be

( )6!

6, 4 6 5 4 3 3602!

P = = ⋅ ⋅ ⋅ =

A few more distinguishable permutations are given in the following table.

2 Sometimes permutations are written with round parenthesis, such as ( )ab ab= . . 3 If we interchanged the two S’s we would get two different permutations, SYSTEM and SYSTEM, but they are

not distinguishable permutations since the S’s look alike.

Page 7: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 189 Combinatorics

189

Word Indistinguishable Permutations

too 3

32

!

!=

error 5

203

!

!=

toot 4

62 2

!

! !=

Mississippi 11

69 3004 4

!,

! !=

Distinguishable Permutations

Table 2

A second application of the multiplication principle is computing

combinations.

Combinations

Combinations are essentially permutations where order doesn’t matter.

For example, for a set with three members { }, ,c a t , a combination of two

members of this set is a subset of size two. There are three such subsets, or

combinations, which are

{ } { } { }, , , , ,a c a t c t

Note that we write these three combinations in set notation { },x y since the

order of the members in the combination does not matter. In other words, the

combination { },a c is the same as the combination { },c a . This is different from

permutations where the permutation ab is not the same as the permutation ba .

Definition: Definition: Definition: Definition: A combinationcombinationcombinationcombination is a subset of elements of a set.

Example Example Example Example 5555 Find the combinations or subsets of size 1, 2 and 3r = taken from

the set { }, ,a b c .

SolutionSolutionSolutionSolution

It is a simple task to enumerate these combinations, which are listed

Table 3. Note that the 8 subsets of { }, ,a b c with the exception of the empty

Page 8: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 190 Combinatorics

190

set ∅ are listed. If we wanted a subset of size 0 we would include the empty

set.

1r = 2r = 3r =

{ }a { },a b { }, ,a b c

{ }b { },a c

{ }c { },b c

Nonempty Subsets of { }, ,a b c

Table 3

TheTheTheTheorem 2:orem 2:orem 2:orem 2: Number of Combinations Number of Combinations Number of Combinations Number of Combinations The number of combinationscombinationscombinationscombinations (or

subsets) of size r which can be selected from a set of size n , which we

denote by ( ), or n

rC n r

, is

( )( )

!,

! !

n nC n r

r r n r

= =

− ....

Proof:Proof:Proof:Proof:

Recall that the number of permutations of size r elements taken from a

set of size n is ( )( )

!,

!

nP n r

n r=

−. However, these r elements can be

permuted in !r ways, so to count only one of these !r permutations, we

divide ( , )P n r by !r getting

( )( )

( ), !

,! ! !

P n r nC n r

r r n r= =

−.

The numbers ( ), or n

C n rr

are called binomial coefficientsbinomial coefficientsbinomial coefficientsbinomial coefficients because they are

the coefficients in the binomial expansion

Page 9: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 191 Combinatorics

191

( )

( )

( )

2 2 2 2 2

3 3 2 2 3 3 2 2 3

4 4 3 2 2 3 4 4 3 2 2 3 4

2 2 22

0 1 2

3 3 3 33 3

0 1 2 3

4 4 4 4 44 6 4

0 1 2 3 4

..

a b a ab b a ab b

a b a a b ab b a a b ab b

a b a a b a b ab b a a b a b ab b

+ = + + = + +

+ = + + + = + + +

+ = + + + + = + + + +

. ... ... ... ... ...

.

It helps in thinking about combinations to say n

r

as "n choose "r since it

denotes the number of ways one can choose r items from a set of n items.

For example 4

62

=

is read as “4 choose 2 is 6” which means there are 6

ways to choose 2 things from 4 things.

Margin Note: Margin Note: Margin Note: Margin Note: Combinations: Order does not matter

Example Example Example Example 6666 How many ways can 10 players choose up sides to play five-

on-five in a game of basketball?

SolutionSolutionSolutionSolution

As in many combinatorial problems, there is more than one way to do the

counting. Perhaps the simplest way here is to determine the number of ways

one player can choose his or her four teammates from the 9 other players. In

other words, the number of subsets of size four taken from a set of size 9, or

“nine choose four”, which is

9 9! 9 8 7 6

126 ways 4 4!5! 4 3 2 1

⋅ ⋅ ⋅= = =

⋅ ⋅ ⋅ .

Another approach is to find number of subsets of size 5 taken from a set of

size 10 and divide that number by 2, getting

101 1 10! 1 10 9 8 7 6

12652 2 5!5! 2 5 4 3 2 1

⋅ ⋅ ⋅ ⋅= ⋅ = ⋅ =

⋅ ⋅ ⋅ ⋅

Page 10: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 192 Combinatorics

192

Example 7 (Number of World Series)Example 7 (Number of World Series)Example 7 (Number of World Series)Example 7 (Number of World Series) How many possible ways can two

teams play a best-of-seven game World Series4? For example, two outcomes

are WWWW (sweep) and WLWWLW which means the winner wins games

1,34,6 in a 6-game series.

Solution:Solution:Solution:Solution: The series might run 4, 5, 6, or 7 games. However, since the winner

eventually wins 4 games, we simply ask how many ways can we place 4 W’s in

7 slots:

1 2 3 4 5 6 7

For example, a 4-game sweep would correspond to

WWWW WWWW WWWW WWWW 5 6 7

and a 6-game series in which the winner wins games 1,3,4, and 6 would

correspond to

WWWW 2 WWWW WWWW 5 WWWW 7

Hence, the total number of series that can be played is 7 choose 4, or

( )7 4 35,C = .

In general, the number of series that can be played in a best of 2 1n +

game series is ( )2 1 1,C n n+ + . We could analyze the series further by asking

the possible number of 4,5,6, and 7 game series. These would be

( )( )( )( )

Number of 4-game series 3 3 1

Number of 5-game series 4 3 4

Number of 6-game series 5 3 10

Number of 7-game series 6 3 20

,

,

,

,

C

C

C

C

= =

= =

= =

= =

The idea behind these numbers is that the winner must win 4 games and the

last game of the series is always won by the winner. Hence, we simply ask

the number of ways the teams can play the series before the last game. For

example, in a 6-game series, how many possible series games will be played

before the last game? The answer is the number of ways you can put 3 wins

in 5 games, or “5 choose 3” which is ( )5 3 10,C = .

4 We assume the reader knows the World Series is a best-of-7 game series.

Page 11: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 193 Combinatorics

193

It is interesting to note that of all the World Series between 1903 and 2009,

eleven series have never occurred, one being WLLLWWW when the winner wins

games 1,5,6, and 7. The most common outcome is the four-game sweep

WWWW, which has occurred 15 times

PPPPoker Handsoker Handsoker Handsoker Hands

In poker, five cards are dealt from a deck of 52 cards. The types of

poker hands (and examples) are

1111 Royal Flush:Royal Flush:Royal Flush:Royal Flush: A, K, Q, J, 10 of the same suit (10♠, J♠, Q♠,K♠,A♠ )

2 Straight Flush: Five cards of same suit in sequence (3♣,4♣,5♣,6♣,7♣ )

3 4 of a Kind: Four cards of the same rank (7♦,7♠,7♣,7♥)

4 Full House: Three of a kind plus a pair (7♠,7♣,7♥,9♦,9♥)

5 Flush: Five cards of the same suit (3♥,6♥,K♥,9♥,A♥ )

6 Straight: Five cards in sequence (4♥,5♦,6♠,7♥,8♠ )

7777 3 of a Kind:3 of a Kind:3 of a Kind:3 of a Kind: Three cards of the same rank (J♥, J♠, J♦)

8888 2 Pairs:2 Pairs:2 Pairs:2 Pairs: Two pairs of different rank (5♣, 5♥, 9♦, 9♠)

9 1 Pair: Two cards of the same rank (A♣, A♥)

Find a) the total number of poker hands, b) the number of 4-or-a-kinds, c) the

number of full houses, d) the number of 3-of-a-kind hands.

Solution:

a) Total Hands:Total Hands:Total Hands:Total Hands: Each hand represents a subset of size 5 from a set of size 52.

Hence the total number of hands a player can receive is “52 choose 5” or

52 52! 52 51 50 49 48

2,598,960 total hands5 5!47! 5 4 3 2

⋅ ⋅ ⋅ ⋅= = =

⋅ ⋅ ⋅

b) 4444----ofofofof----aaaa----kindkindkindkind:::: There are 13

131

=

ways to select the “quads” and

4848

1

=

choices for the remaining card. Using the multiplication principle, we get

Page 12: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 194 Combinatorics

194

48 13

48 13 6244 four of a kind hands1 1

= ⋅ =

c) Full House:Full House:Full House:Full House: There are 13

131

=

choices for the rank of the triple, and

1212

1

=

choices for the rank of the pair. There are also

44

3

=

ways to

choose the triple from a card of a given rank, and 4

62

=

ways to choose the

pair from four cards of the other rank. Hence, the multiplication principle gives

us

13 12 4 4

13 12 4 6 3,744 full house hands1 1 3 2

= ⋅ ⋅ ⋅ =

d) Three of a Kind:Three of a Kind:Three of a Kind:Three of a Kind: There are 13

131

=

choices for the rank of the triple, and

1266

2

=

choices for the rank of the remaining 2 cards. There are also

44

3

=

choices for the triple of the given rank, and

44

1

=

for each of the

remaining two cards. Using the multiplication principle, we have

313 12 4

54,912 3-of-a-kind hands1 2 1

=

Naming Naming Naming Naming Results Results Results Results in Mathematicsin Mathematicsin Mathematicsin Mathematics It is a sorry state of affairs that in mathematics,

the most precise of all disciplines, is so lax about giving credit to those who

made major discoveries. Pascal’s triangle was well known by many

mathematicians centuries before Pascal described it in a paper, so why is it

called “Pascal’s triangle?” It probably goes back to some person giving credit

to Mr. Pascal, and others picking up on that. After a while it becomes “Pascal’s

triangle.” Mathematics is rife with all sorts of equations and theorems

attributed to one person that were actually discovered by another.

Example Example Example Example 8888 (Going to the Movies) (Going to the Movies) (Going to the Movies) (Going to the Movies)

Three boys and two girls are going to a movie. How many ways can

they sit next to each other under the following conditions?

Page 13: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 195 Combinatorics

195

a) Neither boy sits next to each other.

b) The two girls sit next to each other.

SolutionSolutionSolutionSolution

a) The only way they can sit is boy-girl-boy-girl-boy. But the boys can

be permuted 3! 6= ways and the girls 2! 2= ways, so the total number of

arrangements is 3!2! 12= .

b) First think of the two girls as “one girl” so there are 4 persons; 3 boys

and 1 girl. But there are 4! 24= ways to permute the “girl” among the 3 boys.

But, for each of these arrangements, we can permute the two girls 2! 2=

ways, and so the total number of arrangements is 4!2! 48= .

Example Example Example Example 9999 (Marbles and Bins) (Marbles and Bins) (Marbles and Bins) (Marbles and Bins)

John is handing out 10 pieces of corn candy to 4 children in such a way

that every child gets at least one piece. How many different ways can John

distribute the candy?

SolutionSolutionSolutionSolution

Many combinatorial problems seem difficult until viewed from a certain

perspective. This is one of those problems. The idea here is to line up the 10

pieces of candy in a row like

And separate the candy with three bars like

which is our way of saying John gives the first child 2 pieces of candy, the

second child 3 pieces, the third child 4 pieces, and the last child 1 piece.

Another way to think of it is there are 9 gaps between the candy and we put

the bars in gaps 2,5, and 9 which is the same as picking the combination

Page 14: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 196 Combinatorics

196

{ }2 5 9, , from the set { }1 2 3 4 5 6 7 8 9, , , , , , , , . Hence, the number of ways to put 3

bars between 9 pieces of candy is the binomial coefficient

9 9

843 6 3

!

! !

= =

which is the number of ways John can distribute the 10 pieces of candy to four

children.

In general, the number of ways to distribute n pieces of candy to k children

where every child gets at least one piece is ( )1 1,C n k− − .

Example Example Example Example 10101010 (Finding Paths) (Finding Paths) (Finding Paths) (Finding Paths)

How many paths are there from Start to End in the road system in Figure

4, always moving to the right and down?

SolutionSolutionSolutionSolution

Counting Paths

Figure 4

SolutionSolutionSolutionSolution Since all paths pass through the “one-point” gap, the problem is

subdivided into two parts; finding the paths from Start to the gap, then finding

the paths from the gap to End, then multiplying the results together. From

Start to the gap, note that we travel a total of eight “blocks,” four blocks to

the right and four blocks down. Labeling each block as R or D , depending

whether the move to the right or down, all paths can be written

{ }, , , , , , ,x x x x x x x x , where four of the 'x s are R and four are D . Hence, the

total number of paths is the number of ways you can select 4 'D s (or 4 'R s )

from a set of size 8, which is “8 choose 4” or ( )8, 4 70C = . Similarly, the

Page 15: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 197 Combinatorics

197

number of paths from the “gap” to End is ( )7,3 35C = Hence, the total number

is

8 7

70 35 2, 450 paths.4 3

= ⋅ =

.

CCCCombinatorial Combinatorial Combinatorial Combinatorial Card Trickard Trickard Trickard Trick5555♠♠♠♠

Here is a little trick you and a friend can perform before an audience.

It’s very clever and involves two principles of combinatorics, the pigeonhole

principle6 and the fact that a set with three elements has 6 permutations. You

can be the magician and your friend the assistant. Beginning with a deck of 52

playing cards, choose a volunteer from the audience to select five cards at

random from the deck and gives them to the assistant. The assistant looks at

the cards, places one card face down on a table, and the other four face up.

You then perform your magic by studying the four upright cards, waving your

magic wand, and announcing the 5th card to the audience. How did you do it?

To show how the trick is done, someone the person in audience has

selected the cards shown in Figure 5.

Selected Cards

Figure 5

Now, since there are four suits in the deck and since five cards are selected,

the Pigeonhole Principle requires at least one suit will appear more than once.

After your assistant receives the cards, he (or she) focuses on the repeated

5 This trick has been attributed to mathematician William Fitch Cheney. For more variations on this

trick, google “Cheney’s Five Card Trick.” 6 The pigeonhole principlepigeonhole principlepigeonhole principlepigeonhole principle is a rather obvious principle from combinatorics which states if

m objects are attempted to be placed in n boxes and if m n> , then at least one box contains

more than one object. The principle is sometimes stated that if m pigeons try to nest in n

pigeonholes and if m n> , then at least one pigeonhole will contain more than one pigeon.

Page 16: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 198 Combinatorics

198

suit7 (hearts in our example) and computes the smaller clockwise distance

between the 7♥ and 9♥, as illustrated in Figure 6, which is 2. Note that the

minimum distance will always 1,2,3,4,5 or 6. The assistant then selects the

larger 9♥ as the “mystery card” and places it face down on a table. The

remaining four cards {7♥, 7♦, 9♣, 2♠} are placed upright on the table.

Counting clockwise no two cards are more than 6 places apart

Figure 6

But the cards are not placed randomly but in a specific order, and that is what

is crucial. Your assistant places the cards in the following order (from left to

right) as

order of the cards from left to right = (7♥ , 2♠ , 7♦ , 9♣)

So how does this ordering tell you that the mystery card is a 9 of hearts? The

first card on the left tells you that the mystery card is a heart. The remaining

three cards (2♠ , 7♦ , 9♣) give sufficient information to tell you that the

mystery card is two places past the 7♥ which is the 9♥. The idea behind the

code is to rank all 52 cards in the deck according to the ranking

spaces clubs < diamonds hearts< <

and within each suit

2 3A J Q K< < < < < <� .

7 If there is more than one repeated suit, pick one at random.

Page 17: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 199 Combinatorics

199

so the three cards can be ranked according to small (S), medium (M), and

large (L). In this way, your assistant can encode one of the numbers 1,2,3,4,5

or 6 by placing the cards in one of the 6 permutations

1 2

3 4

5 6

SML SLM

MSL MLS

LSM LMS

= =

= =

= =

In our example, your assistant has laid out the three cards as 2♠ 7♦ 9♣

whose ranking is SLM whose code is 2. So after viewing these cards you

perform some quick mental calculations, and decode the mystery cards and

move 2 places past the 7 and arrive at the 9♥, whereupon you wave your

magic wand and announce the card to the amazed audience8.

8 The audience will be amazed. The author has performed this trick. The audience will also be

suspicious, thinking your assistant passed the identity of the card to you in some surreptitious

manner.

Page 18: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 200 Combinatorics

200

SeSeSeSection 2.3, Combinatoricsction 2.3, Combinatoricsction 2.3, Combinatoricsction 2.3, Combinatorics

1. Compute the following.

a) (5,3)P Ans:Ans:Ans:Ans: 5 4 3 60⋅ ⋅ =

b) (4,1)P Ans:Ans:Ans:Ans: 4

c) (30, 2)P Ans:Ans:Ans:Ans: 30 29 870⋅ =

d) (4,1)C Ans:Ans:Ans:Ans: 4

41 3

!

! !=

e) (10,8)C Ans:Ans:Ans:Ans: 10

458 2

!

! !=

f) 7

2

Ans:Ans:Ans:Ans: 7

212 5

!

! !=

g) 9

2

Ans:Ans:Ans:Ans: 9

362 7

!

! !=

h) ( )6

a b+

Ans:Ans:Ans:Ans: 6 5 4 2 3 3 2 4 5 66 15 20 15 6a a b a b a b a b ab b+ + + + + +

Permutations and CombinaPermutations and CombinaPermutations and CombinaPermutations and Combinationstionstionstions

2. (Distinguishable Permutations)(Distinguishable Permutations)(Distinguishable Permutations)(Distinguishable Permutations) The number of distinguishable permuations distinguishable permuations distinguishable permuations distinguishable permuations

of the word TOOTS is 5!

2!2!. Since there are five letters in the word one

writes 5! in the numerator. However, we cannot distinguish the 2 Ts and the 2

Os in the word, hence we divide 2!2!. Find the number of distinguishable

permutations in the following words.

a) TO Ans:Ans:Ans:Ans: 2

21 1

!

! !=

b) TWO Ans:Ans:Ans:Ans: 3

31 1

!

! !=

c) TOO Ans:Ans:Ans:Ans: 3

32 1

!

! !=

Page 19: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 201 Combinatorics

201

d) BOOT Ans:Ans:Ans:Ans: 4

62 2

!

! !=

e) SNOOT Ans:Ans:Ans:Ans: 5

601 1 2 1

!

! ! ! !=

f) DALLAS Ans:Ans:Ans:Ans: 6

1201 2 2 1

!

! ! ! !=

g) TENNESSEE Ans:Ans:Ans:Ans: 9

37801 4 2 2

!

! ! ! !=

h) ILLINOIS Ans:Ans:Ans:Ans: 8

33603 2 1 1

!

! ! ! !=

3. (Goi(Goi(Goi(Going to the Moviesng to the Moviesng to the Moviesng to the Movies)))) Find the numbers of ways in which 4 boys and 4

girls can be seated in a row of 8 seats if they sit alternately and if there is a

boy named Jerry and a girl named Susan who cannot sit next to each other.

Ans: Ans: Ans: Ans: Calling B = boy, G = girl we first count the arrangements of alternating

boy and girl. We can arrange as

B,G,B,G,B,G,B,G 4 4 576 ways

G,B,G,B,G,B,G,B 4 4 576 ways

! !

! !

= × =

= × =

for a total of 576 + 576 = 1152 ways. We now must subtract from this

number the number of ways where Jerry and Susan are sitting next to each

other. The number of ways will be

Jerry, Susan, B,G,B,G,B,G 6 3 3 252 ways

Susan, Jerry, G,B,G,B,G,B 6 3 3 252 ways

! !

! !

= × × =

= × × =

For a total of 252 + 252 = 504 ways. To satisfy the condition that Jerry and

Susan do not sit next to each other we must subtract 504. Hence the total

number of desired arrangements is 1152 – 504 = 648 ways.

4. (Movies Again) (Movies Again) (Movies Again) (Movies Again) Four couples go to the movies and sit together in six seats.

How many ways can these people arrange themselves where each couple sits

next to each other?

Page 20: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 202 Combinatorics

202

Ans:Ans:Ans:Ans: Four couples can arrangement themselves 4! Number of ways, where

each couple can sit two ways. Hence, the total number of ways is

4 2 2 2 192 ways!× × × =

5. (More Movies) (More Movies) (More Movies) (More Movies) Mary and 4 friends go to a movie. How many ways can

they sit next to each other with Mary always between two friends?

Ans:Ans:Ans:Ans: The total number of ways they can sit together is

5 5 4 3 2 1 120!= × × × × = . The total number of ways they can sit together with

Mary on the left is 4!, which is the same as if Mary sat on the right. Hence,

the total number with Mary between two friends is

5 4 4 120 24 24 72 ways! ! !− − = − − =

6. (Baseball Season)(Baseball Season)(Baseball Season)(Baseball Season) A baseball league consists of 6 teams. How many

games will be played over the course of a year if each team plays every other

team exactly 5 times?

Ans:Ans:Ans:Ans: 6 6

5 5 752 2 4

!

! !

= =

7777. . . . (Disti(Disti(Disti(Distinct 3nct 3nct 3nct 3----digit numbers)digit numbers)digit numbers)digit numbers) How many 3-digit numbers are there in which

the number of even digits is 0,2,4,6, or 8 ?

AnsAnsAnsAns: Calling even digits by E and odd digits by O, we can have any 3-digit

numbers of the form EEO, EOE, OEE, and OOO. Now there are 5 even digits

0,2,4,6, 8 and there are 5 odd digits 1,3,5,7,9. However, the number 0 cannot

start the 3-digit number, else the number is a 2-digit number. Hence, using the

multiplication principle, we have

EEO: 4 5 5 100 3-digit numbers of this form

EOE: 4 5 5 100 3-digit numbers of this form

OEE: 5 5 5 125 3-digit numbers of this form

OOO: 5 5 5 125 3-digit numbers of this form

× × =

× × =

× × =

× × =

for a total of 450 possibilities.

8. (Interesting Problem)(Interesting Problem)(Interesting Problem)(Interesting Problem) How many 3-digit numbers 1 2 3

d d d are there whose

digits add up to 8? That is, 1 2 3

8d d d+ + − , Note: 063 is not a 3-digit number,

it is the 2-digit number 63.

Page 21: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 203 Combinatorics

203

Ans: Ans: Ans: Ans: Starting with a 3-digit number 1 2 3

d d d , we start with the hundreds digit

1d , which can have values 1 2 3 4 5 6 7 or 8, , , , , ,k = for a total of 8 possibilities (0

is not a possibility for the hundreds digit else1 2 3

d d d will only be a 2-digit

number. If we now pick the hundreds digit to be k , then the number of

possibilities for the 10-digit 2

d will be 8 1k− + (we need the +1 since now 0

is a possibility). The 1-digit 3

d is now determined and so if we add up

these possibilities of the hundred and ten digit we find

( )8 8 8

1 1 1

8 1 9

8 99 8

272 36

36 ways

k k k

k k= = =

− + = −

⋅= ⋅ −

= −

=

∑ ∑ ∑

9. (World Series Time(World Series Time(World Series Time(World Series Time) Two teams are playing in playoff series. If it is a

best of 3-game series there are three possible outcomes, WW, WLW, LWW if

we do not distinguish the teams. If the teams are distinguished, say team A

and team B, then there would be six outcomes in a 3-game series, AA, ABA,

BAA, BB, BAB, ABB.

a) How many possible games are there is a 5-game series if we do not

distinguish the teams?

b) How many possible games are there is a 2 1n + game series if we do not distinguish the teams?

Ans:Ans:Ans:Ans: a) If we denote the possible games as

1 2 3 4 5

the three W’s can be placed in any 3 slots. Hence the number of possible

games is

5

103

=

b) The W’s can be placed in any 1n + of the 2 1n + possible slots. Hence, the

number of possible games is 2 1

1

n

n

+ +

.

Page 22: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 204 Combinatorics

204

10. ((((BBBBell Numbersell Numbersell Numbersell Numbers)))) A partition of a set A is defined as asset of nonempty

subsets, pairwise disjoint, whose union is A. The number of such partitions

of a set of size n is called the Bell number n

B . For example when 3n = the

Bell number 3

5B = since there are 5 partitions of a set of size 3. For

example, if { }, ,A a b c= the 5 partitions are:

{ } { } { }{ }{ } { }{ }{ } { }{ }{ } { }{ }{ }{ }

, ,

, ,

, ,

, ,

, ,

a b c

a b c

b a c

c a b

a b c

Enumerate the partitions of the set { }, , ,a b c d to find the Bell number 4

B .

Ans:Ans:Ans:Ans: 4

15B =

11. (Two Committees)(Two Committees)(Two Committees)(Two Committees) How many ways can the Snail Darter Society, who has

25 members, elect an executive committee of 2 members and an

entertainment committee of 4 members if no member of the society can

serve on both committees?

Ans:Ans:Ans:Ans: 25 23 25 23

300 1771 531 3002 3 23 2 20 3

! !,

! ! ! !

= = × =

12. (Serving on More than One Committee) (Serving on More than One Committee) (Serving on More than One Committee) (Serving on More than One Committee) How many ways can the

Snail Darter Society, who has 25 members, elect an executive

committee of 2 members, an entertainment committee of 3 members,

and a welcoming committee of 2 members if members can serve on more

than one committee?

Ans:Ans:Ans:Ans: 25 25 25 25 23 25

2 3 2 23 2 20 3 23 2

! ! !

! ! ! ! ! !

=

13. (Counting Softball Teams) (Counting Softball Teams) (Counting Softball Teams) (Counting Softball Teams) A college softball team is taking 25 players on

a road trip. The traveling squad consists of 3 catchers, 6 pitchers, 8

Page 23: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 205 Combinatorics

205

infielders, and 8 outfielders. Assuming each player can only play her own

position, how many different teams can the coach put on the field?

Ans:Ans:Ans:Ans: 25 22 18 10

3 6 8 8

14. (Permutations as Groups)(Permutations as Groups)(Permutations as Groups)(Permutations as Groups) The 3! 6= permutations of set { }1, 2,3 can be

illustrated by the 2 3× arrays

1 2 3

1 2 3α

=

1 2 3

2 3 1β

=

1 2 3

3 1 2γ

=

1 2 3

1 3 2δ

=

1 2 3

2 1 3ε

=

1 2 3

3 2 1η

=

where the bottom row of each array shows how the top row is permuted.

Carrying out one permutation followed by another defines a multiplication

of the permutations. For instance ε δβ= means we do permutationβ first

then permutation δ second, which yields the permutation ε (check it

yourself). Compute the following.

a) αβ

Ans:Ans:Ans:Ans: 1 2 3 1 2 3 1 2 3

1 2 3 2 3 1 2 3 1αβ α

= = =

b) 2α

Ans:Ans:Ans:Ans: 21 2 3 1 2 3 1 2 3

1 2 3 1 2 3 2 3 1α α

= = =

c) 2β

Ans:Ans:Ans:Ans: 21 2 3 1 2 3 1 2 3

2 3 1 2 3 1 3 1 2β γ

= = =

d) δε

Ans:Ans:Ans:Ans: 1 2 3 1 2 3 1 2 3

1 3 2 2 1 3 3 1 2δε γ

= = =

Page 24: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 206 Combinatorics

206

After you get the hang of multiplying permutations, make a 6 6×

multiplication table of all products. This table describes what in group

theory is called the symmetric groupsymmetric groupsymmetric groupsymmetric group of order 3, denoted by 3S .

15. (The Josephus Problem)(The Josephus Problem)(The Josephus Problem)(The Josephus Problem) A thousand Roman slaves are put in a circle

numbered from 1 to 1000. All are to be shot except one lucky survivor.

Slave #1 graciously allows slave #2 to begin, so the order of shooting is

2,4,6,… . After a slave is shot, the body is removed from the circle and the

shooting continues. For example, if there were six slaves the order of the

shooting would be 2,4,6,3,1 and slave #59.

a) Find the position ( )p n of the surviving slave if there are n slaves for

1 2 10, ,...,n = .

Ans: Ans: Ans: Ans:

n 1111 2222 3333 4444 5555 6666 7777 8888 9999 10101010

( )p n 1111 1111 3333 1111 3333 5555 7777 1111 3333 5555

b) Verify that if n is odd, ( )p n satisfies the recurrence relation

( ) ( ) ( )2 1 2 1 1 1,p n p n p+ = + = .

Ans:Ans:Ans:Ans:

( ) ( )( ) ( )( ) ( )( ) ( )

3 2 1 1 2 1 1 3

5 2 2 1 2 1 1 3

7 2 3 1 2 3 1 7

9 2 4 1 2 1 1 3

p p

p p

p p

p p

= + = ⋅ + =

= + = ⋅ + =

= + = ⋅ + =

= + = ⋅ + =

c) Verify that if n is even, ( )p n satisfies the recurrence relation

( ) ( ) ( )2 2 1 2 1,p n p n p= − = .

Ans:Ans:Ans:Ans:

9 The problem is named after Flavius Josephus, a Jewish historian living in the 1st century.

According to legend, he and 40 fellow soldiers were trapped in a cave, surrounded by Romans.

They chose suicide over capture and decided that to form a circle and start killing themselves,

killing alternate persons in the circle.

Page 25: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 207 Combinatorics

207

( ) ( )( ) ( )( ) ( )( ) ( )( ) ( )

2 2 1 1 2 1 1 1

4 2 2 1 2 1 1 1

6 2 3 1 2 3 1 5

8 2 4 1 2 1 1 1

10 2 5 1 2 3 1 5

p p

p p

p p

p p

p p

= − = ⋅ − =

= − = ⋅ − =

= − = ⋅ − =

= − = ⋅ − =

= − = ⋅ − =

d) Which position would you choose if there were 100 slaves in the circle?

Ans:Ans:Ans:Ans: We can use the results from b), c), getting

( ) ( )( ) ( )( ) ( )( ) ( )( ) ( )( ) ( )

3 2 1 1 2 1 1 3

6 2 3 1 2 3 1 5

12 2 6 1 2 5 1 9

25 2 12 1 2 9 1 19

50 2 25 1 2 19 1 37

100 2 50 1 2 37 1 73

p p

p p

p p

p p

p p

p p

= + = ⋅ + =

= − = ⋅ − =

= − = ⋅ − =

= + = ⋅ + =

= − = ⋅ − =

= − = ⋅ − =

Hence, slave #73 is the lucky one.

16. (Catalan Numbers) (Catalan Numbers) (Catalan Numbers) (Catalan Numbers) The Catalan number 1 2 3, , , ,...n

C n = is the number of

different ways a convex polygon with 2n + sides can be subdivided into

triangles. Figure 6 shows the Catalan numbers 1 2 3 4

and , , ,C C C C . Can you

find the Catalan number 5

C ?

Page 26: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 208 Combinatorics

208

First 4 Catalan Numbers

Figure 6

Ans:Ans:Ans:Ans: 42. The general formula for the number of ways n

c to dissect a

convex polygon is 21

1n

nc

nn

= +

.

17. (Famous Apple Problem) (Famous Apple Problem) (Famous Apple Problem) (Famous Apple Problem) We wish to distribute 8 identical apples to 4

children. How many ways is this possible if each child gets at least one

apple?

Ans:Ans:Ans:Ans: Think of the 8 apples in a row like a a a a a a a a . We can distribute

the apples to the 4 children by placing 3 bars | in some of the 7 gaps

between the apples. For example, if we place the bars like

a a | a | a a a a | a

this means we give the first child 2 apples, the second child 1 apple, the

third apple 4 apples, and the 4th child 1 apple. So the total number of ways

to do this is the number of ways of selecting the 3 bars from 7 gaps, or

7 7

35 ways3 3 4

!

! !

= =

.

Page 27: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 209 Combinatorics

209

18181818. (Pigeon Hole Principle) . (Pigeon Hole Principle) . (Pigeon Hole Principle) . (Pigeon Hole Principle) Apply the pigeonhole to prove that at least two

people in New York City have the same number of hairs on their head. Hint:

You may want to make a few assumptions regarding the population of NYC

and the maximum number of hairs on the human head.

Ans:Ans:Ans:Ans: Since there are more people in NYC than any human has hairs on their

head, the pigeon hole states the given result.

19. (Derangements)(Derangements)(Derangements)(Derangements) A derangement is a permutation in which none of the

elements remain in their natural order. For example the only derangements

of ( )1,2,3 are ( ) ( )3,1, 2 and 2,3,1 . Hence we write !3 2= . Nicolas Bernoulli

proved that the number of derangements of a set of size n is

( )

1

1! !

!

kn

k

n nk=

−= ∑

How many derangements are there for the members ( )1,2,3, 4 ?

Enumerate them.

Ans:Ans:Ans:Ans: We begin by putting B,C,D in the first position. If B is in the first

position we put A,C,D in the second position, and so on. Continuing

in this manner we see that there are 9 derangements of 4 objects,

which are : BADC, BCDA, BDAC, CADB, CDAB, CDBA,DABC,

DCAB, DCBA

20202020. . . . (Counting Handshakes)(Counting Handshakes)(Counting Handshakes)(Counting Handshakes) There are 20 people in a room and each person

shakes hands with everyone else. How many handshakes are there?

Ans:Ans:Ans:Ans: The first person shakes hands with 19 other persons, the second

person shakes hands with 18 other persons (since we have already counted

the handshake with the first person). Continuing on, the third person shakes

hands with 17 persons, etc … so the total number of handshakes is

19 20

19 18 17 2 1 190 handshakes2

...×

+ + + + + = =

21. (Counting Functions)(Counting Functions)(Counting Functions)(Counting Functions) How many functions are there from { }, ,A a b c= to

{ }0,1, 2B = ? Write them down and draw the graphs for a few of them.

Page 28: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 210 Combinatorics

210

Ans:Ans:Ans:Ans: The value of the function at a can be either 0 or 1; likewise the value

of the function at b can be 0 or 1; likewise at c . Hence, the total number

of functions is 32 8= . The eight functions, calling them all by f , are

( ) ( ) ( )( ) ( ) ( )( ) ( ) ( )( ) ( ) ( )( ) ( ) ( )( ) ( ) ( )( ) ( ) ( )( ) ( ) ( )

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

, ,

, ,

, ,

, ,

, ,

, ,

, ,

, ,

f a f b f c

f a f b f c

f a f b f c

f a f b f c

f a f b f c

f a f b f c

f a f b f c

f a f b f c

= = =

= = =

= = =

= = =

= = =

= = =

= = =

= = =

22. (Combinatorial Euclidean Algorithm)(Combinatorial Euclidean Algorithm)(Combinatorial Euclidean Algorithm)(Combinatorial Euclidean Algorithm) Finding the greatest integer that

divides two positive integers can be interpreted as a combinatorial problem

where one seeks all possibilities of divisors. However, the method of

finding the greatest common divisor, denoted ( )gcd ,n m , of two natural

numbers ,n m is called the Euclidean AlgorithmEuclidean AlgorithmEuclidean AlgorithmEuclidean Algorithm and avoids the combinatorial

headache of looking through all divisors. The algorithm makes the

fundamental observation that the quotient of divided by m n has the form:

, 0n r

q r mm m

= + ≤ <

where q is the quotient of /n m and r the remainder. Using the basic

property10 ( ) ( )gcd , gcd ,n m m r= , it is possible to find a sequence of

“decreasing” gcds, which eventually lead to an obvious gcd. For example,

the greatest common divisor of 255 and 68 is 17 as seen from the

“decreasing” sequence of gcds:

( ) ( ) ( ) ( )gcd 255,68 gcd 68,51 gcd 51,17 gcd 17,0 17= = = =

The numbers 51, 17, 0 in the gcds are the remainders of

10 This is true since any whole number that divides both and m n also divides and n r n mq= − ,

and vice versa. true.

Page 29: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 211 Combinatorics

211

255remainder of is 51

68

68remainder of is 17

51

51remainder of is 0

17

Use the Euclidean Algorithm to find the greatest common divisors of the

following pairs of numbers11.

a) ( )gcd 25,3

b) ( )gcd 54,36

c) ( )gcd 900, 22

d) ( )gcd 816,438

Ans:Ans:Ans:Ans:

a) ( )gcd 25,3 1=

b) ( )gcd 54,36 1=

c) ( )gcd 900, 22 6=

d) ( )gcd 816,438 6=

23. (Partitions) (Partitions) (Partitions) (Partitions) A partition of a natural number n is a sequence of natural

numbers 1 2a a≥ ≥� such that 1 2 kn a a a= + + +� for some k . There are two

partitions of 2, which are 2 2, 2 1 1= = + , which we denote by 2, 11. There are

three partitions of 3, which are 3 3, 3 2 1, 3 1 1 1= = + = + + , which we denote by 3,

21, 111. Find the partitions of 4, 5 and 6. How would you construct a total

order for the partitions of the natural numbers? You are relieved from finding

the partitions of 200n = since there are 3,972,999,029,388 of them.

Ans:Ans:Ans:Ans: The partitions of 4 are 1111, 211, 22, 31, and 4 . The partitions of

5 are 11111, 2111, 221, 311, 32, 41, 5 . There are 11 partitions of 6 ,

which are 111111, 21111, 2211, 3111, 222, 321, 411, 33, 42, 51, 6.

A total order " "≺ for a partition is 1 2 1 2a a b b+ + + +�≺ � if and only if

11 There are other methods for finding the greatest common divisor of two natural numbers. One

could factor each natural number into its prime components, find the common factors, then take the

product of the common factors. For example, 816 and 438 have factors of 2 and 3, and so 6 would

be their greatest common divisor.

Page 30: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 212 Combinatorics

212

1 2 1 2k ka a a b b b+ + + ≤ + + +� � for all 1k ≥ . With this ordering we have

4 : 1111 211 22 31 4

5 : 11111 2111 221 311 32 41 5

6 : 11111 21111 2211 222 3111 321 33 411 42 51 6

n

n

n

=

=

=

≺ ≺ ≺ ≺

≺ ≺ ≺ ≺ ≺ ≺

≺ ≺ ≺ ≺ ≺ ≺ ≺ ≺ ≺ ≺

24. . . . (Euler’s Theorem)(Euler’s Theorem)(Euler’s Theorem)(Euler’s Theorem) There are many identities related to integer partitions.

The first one was due to the Swiss mathematician Leonhard Euler who proved

that any number has as many partitions consisting of odd numbers as there are

partitions consisting of distinct numbers. For example, the number 5 has 3

partitions consisting only of odd numbers, 11111, 311, and 5; and 3 partitions

consisting of distinct numbers is 5, 41, 32. Show Euler’s partition identity

holds for the number 6.

AnsAnsAnsAns: Partitions consisting of odd numbers: 111111, 3111, 33, 51 and partitions

of distinct numbers: 321, 42, 51, and 6.

25. (Fun Problem)(Fun Problem)(Fun Problem)(Fun Problem) How many integers are there between 000 and 999

where the middle digit is the average of the other two digits? For example,

246 and 420 satisfy the condition.

AnsAnsAnsAns: Firet make the observation that the first two digits cannot be 0 and

that the only possible numbers where the last digit is 0 are the four

numbers 210, 420, 630, and 840. We now include the nine numbers 111,

222, 333, … , 999 where all the digits are the same. We now list the

remaining possibilities when the middle digit is 2,3,4,… 8. We have

middle digit 2: 123

middle digit 3: 135 234

middle digit 4: 147 246 345

middle digit 5: 159 258 357 456

middle digit 6: 369 468 567

middle digit 7: 579 678

middle digit 8: 789

,

, ,

, , ,

, ,

,

and

Page 31: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 213 Combinatorics

213

middle digit 2: 321

middle digit 3: 531, 432

middle digit 4: 741,642,543

middle digit 5: 951,852,753,654

middle digit 6: 963,864,765

middle digit 7: 975,876

middle digit 8: 987

Counting up these we have ( )2 16 9 4 45+ + = . Now, if you want to be clever,

realize that that the first and last digits must both be odd or both even.

Thus there are 5 5 25⋅ = possible numbers where the first and last digits are

odd, and 5 4 20⋅ = even-even pairs that do not use 0 in the first digit.

Hence we have a total of 25 + 20 = 45 numbers.

26. ((((Basic Basic Basic Basic Pizza CuttingPizza CuttingPizza CuttingPizza Cutting) ) ) ) You are given a circular pizza and ask to cut it into as

many pieces as possible, where a cut means any line that passes all the way

through the pizza, although not necessarily through the center. The picture

below shows a pizza with four typical slices dividing the pizza into 9 pieces of

pizza.12

Typical pizza with 4 cuts and 9 pieces

a) How many different pieces can you obtain with three slices?

b) How many different pieces can you obtain with four slices?

12 We could just as well said that the entire plane can be subdivided into 9 disjoint sections. In fact

normally the “pizza problem” is stated in terms of the entire plane and not simply a the inside of a circle.

Page 32: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 214 Combinatorics

214

c) Show how you can slice a pizza with 4 slices to obtain 5, 6, 7, 8, 9, 10,

and 11 pieces ?

Ans:Ans:Ans:Ans: a) With 3 slices one can obtain 4, 5, 6, or 7 pieces. If none of the

slices intersect then there will be 4 slices, if two slices intersect there will

be 5 slices, etc. Examples are

b) With 4 slices one can obtain 5-11 pieces, depending on the number of

intersections of the slices, assuming the intersections only involve two

slices. We leave this fun problem to the reader. (Note that if all the slices

are all made through the center of the pizza, then the number of pieces of

pizza will be twice the number of slices.)

c) We leave this fun problem for the reader.

Page 33: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 215 Combinatorics

215

27. (Pizza Cutter’s Formula)(Pizza Cutter’s Formula)(Pizza Cutter’s Formula)(Pizza Cutter’s Formula) A pizza cutter wants to cut a pizza in such a

way that it has the maximum number of pieces, not necessarily the same

size or shape. The only restriction on how the pizza is cut is that each cut

much pass all the way through the pizza, not necessary through the center.

Typical Pizza after 3 cuts with 7 pieces

a) If ( )P n is the maximum number of pieces from n cuts, then

( ) ( )1P n P n n= − + .

b) Show the pizza cutter’s formula is

( )2 1

2

n nP n

+ += .

Ans:Ans:Ans:Ans: a) The first line cuts the pizza into 2 pieces, the second piece into a

max of 4 pieces and the third line yields a maximum of 7 pieces, and so on.

We made the n th slice so it cuts the previous 1n − slices (we can do this by

making it very close to the previous slice), hence the n th slice is cut into

n segments, each of those segments cutting one piece of pizza into two

pieces, and so the n th slice yields n new pieces of pizza. Hence, if

( )1P n − is the maximum number of pieces after 1n − cuts, then to maximize

the number after n cuts we make the n -th cut intersect each of the 1n −

cuts, giving an extra n pieces. Hence ( ) ( )1P n P n n= − + .

Page 34: Section 2.3 counting - jerryandsusan.tripod.comjerryandsusan.tripod.com/sec23.pdf · ... eight hundred and forty four octillion, three hundred and ... writing permutations 2 since

Section 2.3 216 Combinatorics

216

b) We can write

( ) ( )( ) ( )( ) ( ) ( )

( )( )

( )

2

1

1 1

2 1 1

1 0 1 2

1 1 2

11

22

2

... ...

P n P n n

P n n n

P n n n n

P n

n

n n

n n

= − +

= − + − + = − + − + − +

= + + + + + = + + + +

+= +

+ +=

Note that for 3n ≥ this is larger than if the pizza cutter made all cuts

through the center of the pizza. If the cuts are made through the center of

the pizza, then the number of pieces is twice the number of cuts. Cutting a

pizza into pieces is the same as cutting the plane into pieces. More

problems along this line is to cut 3-dimensional space by planes, and

higher-dimensional spaces by hyper-planes. The reader can find more

about how to divide spaces by lines, circles, ellipses, etc by “googling”

phrases like “subdividing the plane into regions.”