Mathematics for Computer Science MIT 6.042J/18.062J Combinatorics II Copyright © Radhika Nagpal, 2002. Prof. Albert Meyer & Dr. Radhika Nagpal
Last Week: Counting I Sets Pigeonhole Principle Permutations Bijections, Sum Rule, Inclusion-Exclusion, Product Rule Pigeonhole Principle Permutations Tree Diagrams
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)
The Real Agenda: Poker How many different hands could I get, if I played 5-card draw?
The Real Agenda: Poker (52) (51) (50) (49) (48) How many different hands could I get, if I played 5-card draw? (52) (51) (50) (49) (48)
The Real Agenda: Poker (52) (51) (50) (49) (48) How many different hands could I get, if I played 5-card draw? (52) (51) (50) (49) (48) r-permutation, P(52,5)
Problem: Over-counting These two hands are the same:
Problem: Over-counting These two hands are the same:
Problem: Over-counting These two hands are the same: In fact any permutation of these cards is the same hand (order is irrelevant)
Number of 5-card Hands How much have we over-counted?
Number of 5-card Hands How much have we over-counted? Over-counted EVERY HAND by 5!
Number of 5-card Hands …… How much have we over-counted? Over-counted EVERY HAND by 5! ……
Number of 5-card Hands …… How much have we over-counted? Over-counted EVERY HAND by 5! …… Still approximately 2.5 million possible hands
Combinations C(n,r) = number of different subsets of size r from a set with n elements. C(n,r) = P(n,r) / r!
Combinations C(n,r) = P(n,r)/r! =
Combinations C(n,r) = P(n,r)/r! =
Combinations C(n,r) = P(n,r)/r! =
Combinations C(n,r) = P(n,r)/r! =
Poker: Gambling Table Straight Flush > Four-of-a-kind > Full House > Flush > Straight > Three-of-a-kind > Two pair > One pair > No pair
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: 9s 9d 9c 9h 5h
Poker: Four-of-a-kind 2 spades 2 clubs 2 hearts 2 diamonds . K hearts K diamonds 1 2 3 . 11 (jack) 12 (queen) 13 (king)
Poker: Four-of-a-kind 2 spades 2 clubs 2 hearts 2 diamonds . K hearts K diamonds 1 2 3 . 11 (jack) 12 (queen) 13 (king) Four-of-a-kind = . 48 = 624
Poker: Full House Full House 9s 9c 9d 5s 5c = choose value for the triple + choose 3 suits + choose value for pair + choose 2 suits
In-class Problem 1: Each table should write their solution on their whiteboard.
Incorrect Counting Argument Two pair = Every hand is counted twice 4 4 7 7 5 7 7 4 4 5
Correct Counting Arguments 1. Divide the Theory Pig’s estimate by 2 2. Choose the values of the two pairs together 2-pair =
Division Rule If set B over-counts every element of A by k times then, |B| = k |A|
Permutations vs Combinations Combinations: subsets of size r, order does not matter Permutations: strings of length r, order of elements does matter.
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
Counting Powerset of A P(A) = set of all subsets of A A = {a,b} P(A) = {{}, {a}, {b}, {a,b}}
Counting P(A) Bijection : P(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} | P(A) | = 2n
Counting P(A) |P(A)| = = subsets + subsets + subsets…..subsets of size 0 of size 1 of size 2 of size n
Counting P(A) Identity: |P(A)| = = subsets + subsets + subsets…..subsets of size 0 of size 1 of size 2 of size n Identity:
Poker: Gambling Table Straight Flush = 40 Four-of-a-kind = 624 Full house = 3744 Flush = 5148 Straight = 10240 Three-of-a-kind = 54,912 Two pair =123,552 One pair = 1,098,240 No pair = 1,317,388
In-class Problems