Mathematics for Computer Science MIT 6 042 J18

  • Slides: 35
Download presentation
Mathematics for Computer Science MIT 6. 042 J/18. 062 J Combinatorics II Copyright ©

Mathematics for Computer Science MIT 6. 042 J/18. 062 J Combinatorics II Copyright © Radhika Nagpal, 2002. Prof. Albert Meyer & Dr. Radhika Nagpal April 1, 2002 1

Last Week: Counting I • Sets – Bijections, Sum Rule, Inclusion. Exclusion, Product Rule

Last Week: Counting I • Sets – Bijections, Sum Rule, Inclusion. Exclusion, Product Rule • Pigeonhole Principle • Permutations • Tree Diagrams April 1, 2002 2

This Week: Counting II • • Division Rule Combinations (binomial coefficients) Binomial Theorem and

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) April 1, 2002 3

The Real Agenda: Poker • How many different hands could I get, if I

The Real Agenda: Poker • How many different hands could I get, if I played 5 -card draw? April 1, 2002 4

The Real Agenda: Poker • How many different hands could I get, if I

The Real Agenda: Poker • How many different hands could I get, if I played 5 -card draw? (52) (51) (50) (49) (48) April 1, 2002 5

The Real Agenda: Poker • How many different hands could I get, if I

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) April 1, 2002 6

Problem: Over-counting • These two hands are the same: April 1, 2002 7

Problem: Over-counting • These two hands are the same: April 1, 2002 7

Problem: Over-counting • These two hands are the same: April 1, 2002 8

Problem: Over-counting • These two hands are the same: April 1, 2002 8

Problem: Over-counting • These two hands are the same: • In fact any permutation

Problem: Over-counting • These two hands are the same: • In fact any permutation of these cards is the same hand (order is irrelevant) April 1, 2002 9

Number of 5 -card Hands • How much have we over-counted? April 1, 2002

Number of 5 -card Hands • How much have we over-counted? April 1, 2002 10

Number of 5 -card Hands • How much have we over-counted? • Over-counted EVERY

Number of 5 -card Hands • How much have we over-counted? • Over-counted EVERY HAND by 5! April 1, 2002 11

Number of 5 -card Hands • How much have we over-counted? • Over-counted EVERY

Number of 5 -card Hands • How much have we over-counted? • Over-counted EVERY HAND by 5! …… April 1, 2002 12

Number of 5 -card Hands • How much have we over-counted? • Over-counted EVERY

Number of 5 -card Hands • How much have we over-counted? • Over-counted EVERY HAND by 5! Still approximately 2. 5 million possible hands …… April 1, 2002 13

Combinations • C(n, r) = number of different subsets of size r from a

Combinations • C(n, r) = number of different subsets of size r from a set with n elements. C(n, r) = P(n, r) / r! April 1, 2002 14

Combinations • C(n, r) = P(n, r)/r! = April 1, 2002 15

Combinations • C(n, r) = P(n, r)/r! = April 1, 2002 15

Combinations • C(n, r) = P(n, r)/r! = April 1, 2002 16

Combinations • C(n, r) = P(n, r)/r! = April 1, 2002 16

Combinations • C(n, r) = P(n, r)/r! = April 1, 2002 17

Combinations • C(n, r) = P(n, r)/r! = April 1, 2002 17

Combinations • C(n, r) = P(n, r)/r! = April 1, 2002 18

Combinations • C(n, r) = P(n, r)/r! = April 1, 2002 18

Poker: Gambling Table Straight Flush > Four-of-a-kind > Full House > Flush > Straight

Poker: Gambling Table Straight Flush > Four-of-a-kind > Full House > Flush > Straight > Three-of-a-kind > Two pair > One pair > No pair April 1, 2002 19

Poker: Four-of-a-kind • Card: value (13) + suit (4) • Four-of-a-kind – 4 cards

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 s 9 d 9 c 9 h 5 h April 1, 2002 20

Poker: Four-of-a-kind 1 2 3. . 11 (jack) 12 (queen) 13 (king) 2 spades

Poker: Four-of-a-kind 1 2 3. . 11 (jack) 12 (queen) 13 (king) 2 spades 2 clubs 2 hearts 2 diamonds. . K hearts K diamonds April 1, 2002 21

Poker: Four-of-a-kind 1 2 3. . 11 (jack) 12 (queen) 13 (king) Four-of-a-kind =

Poker: Four-of-a-kind 1 2 3. . 11 (jack) 12 (queen) 13 (king) Four-of-a-kind = 2 spades 2 clubs 2 hearts 2 diamonds. . K hearts K diamonds . 48 = 624 April 1, 2002 22

Poker: Full House • Full House 9 s 9 c 9 d 5 s

Poker: Full House • Full House 9 s 9 c 9 d 5 s 5 c = choose value for the triple + choose 3 suits + choose value for pair + choose 2 suits April 1, 2002 23

In-class Problem 1: Each table should write their solution on their whiteboard. April 1,

In-class Problem 1: Each table should write their solution on their whiteboard. April 1, 2002 24

Incorrect Counting Argument • Two pair = • Every hand is counted twice –

Incorrect Counting Argument • Two pair = • Every hand is counted twice – 44775 – 77445 April 1, 2002 25

Correct Counting Arguments 1. Divide the Theory Pig’s estimate by 2 2. Choose the

Correct Counting Arguments 1. Divide the Theory Pig’s estimate by 2 2. Choose the values of the two pairs together 2 -pair = April 1, 2002 26

Division Rule • If set B over-counts every element of A by k times

Division Rule • If set B over-counts every element of A by k times then, |B| = k |A| April 1, 2002 27

Permutations vs Combinations • Combinations: subsets of size r, – order does not matter

Permutations vs Combinations • Combinations: subsets of size r, – order does not matter • Permutations: strings of length r, – order of elements does matter. April 1, 2002 28

Calculating Permutations and Combinations • Closely related: C(n, r) = P(n, r) / r!

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 April 1, 2002 29

Counting Powerset of A P(A) = set of all subsets of A • A

Counting Powerset of A P(A) = set of all subsets of A • A = {a, b} • P(A) = {{}, {a}, {b}, {a, b}} April 1, 2002 30

Counting P(A) • Bijection : P(A) and binary strings of length |A| A =

Counting P(A) • Bijection : P(A) and binary strings of length |A| A = {a 1 a 2 a 3 a 4 a 5……an} Binary String = 1 0 1 0…. . 0 Subset of A = {a 1, a 3, a 5} | P(A) | = 2 n April 1, 2002 31

Counting P(A) • |P(A)| = = subsets + subsets…. . subsets of size 0

Counting P(A) • |P(A)| = = subsets + subsets…. . subsets of size 0 of size 1 of size 2 of size n April 1, 2002 32

Counting P(A) • |P(A)| = = subsets + subsets…. . subsets of size 0

Counting P(A) • |P(A)| = = subsets + subsets…. . subsets of size 0 of size 1 of size 2 of size n Identity: April 1, 2002 33

Poker: Gambling Table Straight Flush = 40 Four-of-a-kind = 624 Full house = 3744

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 April 1, 2002 34

In-class Problems April 1, 2002 35

In-class Problems April 1, 2002 35