4
C SC 345 Review of Counting and Combinatorics Casey Irvine January 14, 2011 1 Notation 1.1 Factorial The explicit definition of factorial is as follows: n! := Q n-1 i=0 (n - i)= n(n - 1)(n - 2) ... (2)(1) : n> 0 1 : n =0 Where n Z. The recursive (implicit) definition can be useful to know as well. n! := n(n - 1)! : n> 0 1 : n =0 We usually use factorial in situations where we are choosing objects from a group without replacing them. In other words, duplicate objects are not allowed. For instance: Suppose we want to know how many ways one can uniquely order the numbers 1,2,3,4, and 5. Another way to phrase this question is “How many permutations of 1,2,3,4,5 are there?”. The answer is 5!. 1

CountingReview

Embed Size (px)

Citation preview

Page 1: CountingReview

C SC 345 Review of Counting andCombinatorics

Casey Irvine

January 14, 2011

1 Notation

1.1 Factorial

The explicit definition of factorial is as follows:

n! :=

{ ∏n−1i=0 (n− i) = n(n− 1)(n− 2) . . . (2)(1) : n > 0

1 : n = 0

Where n ∈ Z.

The recursive (implicit) definition can be useful to know as well.

n! :=

{n(n− 1)! : n > 01 : n = 0

We usually use factorial in situations where we are choosing objects from a

group without replacing them. In other words, duplicate objects are notallowed. For instance:

Suppose we want to know how many ways one can uniquely order thenumbers 1,2,3,4, and 5. Another way to phrase this question is “How manypermutations of 1,2,3,4,5 are there?”. The answer is 5!.

1

Page 2: CountingReview

1.2 Binomial Coefficient

We define the binomial coefficient in terms of factorials(n

k

)=

n!

k!(n− k)!

We commonly say “n choose k” or “n pick k”. The binomial coefficient isused when we want to calculate the number of ways a subset of objects canbe chosen from a set.

2 Examples

In this section we want to be able to answer some questions about hands inPoker. For those who are lacking previous experience with poker somebackground info is required. Poker is a card game played with a 52 carddeck. There are four suites: Hearts, Diamonds, Clubs, Spades. Each of thesuites has 13 cards ranked from 2 to 10, Jack, Queen, King, Ace. A hand inmost games of Poker consists of 5 cards dealt in a pseudo-random fashion.We will be discussing the Straight and the Flush. A Straight is when aplayer’s hand consists of a sequence of adjacent cards e.g. 2,3,4,5,6. AFlush is when a player’s hand consists of only one suite e.g. all hearts. AStraight Flush is both a Straight and a Flush in the same hand.

The question we want to be able to answer is “How many ways can one geta Straight?”. Breaking questions down into easier, similar sub-questions isoften helpful with counting problems.

2.1 How many ways can one get a Straight Flushwith the 2 of Hearts as the lowest card?

The specificity of this question should set off some alarms. There is onlyone way in which this hand can be configured: 2H,3H,4H,5H,6H. Once wepick that the lowest card is the 2 of Hearts, we need 4 other cards. Thenext higher card has to be the 3 of Hearts, etc. So, we are given the firstcard, and there is only 1 way to choose the next card, and there is only 1way to choose the third card, and only 1 way to choose the fourth card,and only 1 way to choose the fifth card. Recall the convention is “and” isassociated with multiplication and “or” is associated with addition. We“translate” the above sentence into 1 · 1 · 1 · 1 · 1 = 1.

2

Page 3: CountingReview

2.2 How many ways can one get a Straight Flushwith a 2 as the lowest card?

How many ways can we pick the lowest card in this hand? It could be 2Hor 2D or 2C or 2S; so 4 ways. After the first card is chosen we cannotchange suites. This means there is only 1 way to choose the next card andthe next, etc. This translates to 4 · 1 · 1 · 1 · 1 = 4.

2.3 How many ways can one get a Straight Flush?

How many ways can we pick the lowest card in this hand? The onlypossible lowest cards in a straight is 2,3,. . . ,10. So 9 values with 4 suitesgives us 4 · 9 = 36 ways. Once again, when the lowest card is chosen wecannot change suites. This gives us 36 · 1 · 1 · 1 · 1 = 36 ways.

2.4 How many ways can one get a Straight with a 2as the lowest card?

How many ways can we pick the lowest card in this hand? We could choosea 2 from one of the 4 suites so

(41

)= 4. The next card has to be a 3, but

this time we can change suites. It is the same for the rest of the cards inthe hand. So, we have 4 · 4 · 4 · 4 · 4 = 45 = 1024 ways.

2.4.1 What if we want to exclude Straight Flushes?

One way to think about this is in terms of sets. We have the set of allpossible Straights starting with a 2 and all possible Straight Flushesstarting with a 2. Where do they overlap? The set of Straight Flushes is asubset of the set of Straights. To exclude the Straight Flushes we simplyneed to subtract the cardinality of the intersection. We calculated theoverlap in section 2.2. This gives us 1024− 4 = 1020 ways.

3

Page 4: CountingReview

2.5 How many ways can one get a Straight?

Using what has been discussed in the above sections we should be ableanswer this question. How many ways can we pick the lowest card? Wehave to choose both a suite and a value for the lowest card. We know thatthere are only 9 possible cards that can start a Straight (see 2.3). Thisgives us

(91

)·(41

)= 9 · 4 = 36 ways. What about the next card? Well,

section 2.4 tells us 4 ways. It is the same for the rest of the cards. Thisgives us 36 · 4 · 4 · 4 · 4 = 9216 ways.

4