Mathematics for Computer Science
MIT 6.042J/18.062J
Combinatorics II
L8-1.1
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Last Week: Counting I
• Sets
– Bijections, Sum Rule, InclusionExclusion, Product Rule
• Pigeonhole Principle
• Permutations
• Tree Diagrams
L8-1.2
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
This Week: Counting II
•
•
•
•
Division Rule
Combinations (binomial coefficients)
Binomial Theorem and Identities
Permutations with limited repetition
(multinomial coefficients)
• Combinations with repetition (stars and bars)
L8-1.3
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
The Real Agenda: Poker
• How many different hands could I get, if I
played 5-card draw?
(52) (51) (50) (49) (48)
r-permutation, P(52,5)
L8-1.4
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Problem: Over-counting
These two hands are the same:
In fact any permutation of these cards is
the same hand (order is irrelevant)
L8-1.5
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Number of 5-card Hands
• How much have we over-counted?
• Over-counted EVERY HAND by 5!
Still
approximately
2.5 million
possible hands
……
L8-1.6
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Combinations
• C(n,r) = number of different subsets of
size r from a set with n elements.
C(n,r) = P(n,r) / r!
n
n!
(
n
r
)!
r
!
r
L8-1.7
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Combinations
• C(n,r) =
n!
P(n,r)/r! =
(n r )! r!
n
1
0
n
n
1
n
1
n
n
n
n 1
L8-1.8
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Poker: Gambling Table
Straight Flush
> Four-of-a-kind
> Full House
> Flush
> Straight
> Three-of-a-kind
> Two pair
> One pair
> No pair
L8-1.9
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Poker: Four-of-a-kind
• Card: value (13) + suit (4)
• Four-of-a-kind
– 4 cards with the same value
– 1 with a different value
EXAMPLE: 9 9 9 9 5
L8-1.10
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Poker: Four-of-a-kind
1
2
3
.
.
11 (jack)
12 (queen)
13 (king)
Four-of-a-kind =
13
1
2
2
2
2
.
.
K
K
· 48 = 624
L8-1.11
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Poker: Full House
• Full House 9 9 9 5 5
= choose value for the triple + choose 3 suits +
choose value for pair + choose 2 suits
13 4 12 4
1 3 1 2
L8-1.12
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
In-class Problem 1:
Each table should write their
solution on their whiteboard.
L8-1.13
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Incorrect Counting Argument
13 4 12 4
• Two pair = 44
1 2 1 2
• Every hand is counted twice
–44775
–77445
L8-1.14
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Correct Counting Arguments
1. Divide the Theory Pig’s estimate by 2
2. Choose the values of the two pairs together
13 4 4
2-pair = 44
2 2 2
L8-1.15
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Division Rule
• If set B over-counts every element of A
by k times then,
|B| = k |A|
L8-1.16
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Permutations vs Combinations
• Combinations: subsets of size r,
– order does not matter
• Permutations: strings of length r,
– order of elements does matter.
L8-1.17
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Calculating Permutations and
Combinations
• Closely related: C(n,r) = P(n,r) / r!
• C(n,r) = count all r-permutations, every
combination is over-counted by r!
• P(n,r) = choose r items, then take all
permutations of the items
L8-1.18
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Counting Powerset of A
(A) = set of all subsets of A
• A = {a,b}
• (A) = {{}, {a}, {b}, {a,b}}
L8-1.19
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Counting (A)
• Bijection : (A) and binary strings of length |A|
A = {a1 a2 a3 a4 a5……an}
Binary String = 1 0 1 0 1 0…..0
Subset of A = {a1, a3, a5}
| (A) | = 2
n
L8-1.20
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Counting
n n n
n
• |(A) | =
0 1 2
n
= subsets + subsets + subsets…..subsets
of size 0 of size 1 of size 2 of size n
n
Identity:
k 0
n
k
2
n
L8-1.21
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
Poker: Gambling Table
Straight Flush
Four-of-a-kind
Full house
Flush
Straight
Three-of-a-kind
Two pair
One pair
No pair
Total
= 40
= 624
= 3,744
= 5,148
= 10,240
= 54,912
= 123,552
= 1,098,240
= 1,317,388
= 2,598,960
101
102
103
103
104
104
105
106
106
106
L8-1.22
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
In-class Problems
L8-1.23
Copyright © Radhika Nagpal, 2002. All rights reserved.
April 1, 2002
© Copyright 2026 Paperzz