500 likes | 854 Views
More Combinatorics: Permutations & Combinations. Sections 6.3-6.5. Counting techniques. Bijections Sum rule, product rule Pigeonhole principle Permutations & combinations Inclusion-exclusion. ✔ ✔ ✔. Review: Bijections.
E N D
More Combinatorics:Permutations & Combinations Sections 6.3-6.5 COMBINATORICS
Counting techniques • Bijections • Sum rule, product rule • Pigeonhole principle • Permutations & combinations • Inclusion-exclusion ✔ ✔ ✔ COMBINATORICS
Review: Bijections • If there is a bijection from A to B, , then |A| = |B| f A B . . . . . . COMBINATORICS
Review: Product Rule • If a task T can be broken down into a sequence of two tasks T1 and T2 such that • an outcome of T1 and an outcome of T2 determine a unique outcome of T and • there are n1 possible outcomes of T1 and n2 possible outcomes of T2 then there are (n1n2) possible outcomes of T. • The rule generalizes to any number of independent sub-tasks. COMBINATORICS
Review: Sum Rule • If there are two different ways that a task T can be performed • both ways produce disjoint sets of outcomes • the first way produces n1 outcomes and the second produces n2 outcomes then task T can produce n1 + n2 outcomes. • The rule generalizes to an arbitrary number of ways to perform T; the different ways must produce pair-wise disjoint outcomes. COMBINATORICS
Review: Generalized Pigeonhole Principle • If you have n pigeons and k pigeonholes, at least one pigeonhole must contain at least n/k pigeons COMBINATORICS
Review: Generalized Pigeonhole Principle • If you have n pigeons and k pigeonholes, at least one pigeonhole must contain at least n/k pigeons COMBINATORICS
Review: Generalized Pigeonhole Principle • If you have n pigeons and k pigeonholes, at least one pigeonhole must contain at least n/k pigeons COMBINATORICS
Review: Generalized Pigeonhole Principle • If you have n pigeons and k pigeonholes, at least one pigeonhole must contain at least n/k pigeons COMBINATORICS
Selection/Arrangement of Objects Many counting problems involve selection and/or arrangement of objects. Issues in solving such problems include: Are objects unique? Does the order matter? Is replacement/repetition allowed? 10 COMBINATORICS
Arrangements of objects • There are 45 contestants in a marathon. First, second and third place prizes of $1000, $500, and $100, resp., will be awarded. How many possible outcomes are there? • Rephrasing: How many 3-person orderings can be made from a set of 45 people? • Order matters (arrangement problem) • Replacement/repetition is not allowed • Objects to be arranged are unique • How many? 45 44 43 COMBINATORICS
Arrangements of objects • Definition: An r-permutation is an ordered arrangement of r distinct elements. • Definition: P(n,r) denotes the number of r-permutations from a set with n elements • Theorem: P(n,r) = • Choose the first element of the arrangment (n ways) • Choose the second element (n – 1 ways) • . . . • Choose the rth element (n – r + 1 ways) • By product rule, altogether: n(n-1)(n-2)…(n-r+1) = COMBINATORICS
Arrangements of objects • There are 45 contestants in a marathon. First, second and third place prizes of $1000, $500, and $100, resp., will be awarded. How many possible outcomes are there? • Rephrasing: How many 3-permutations of 45 people? • How many? P(45, 3) = (45!)/(42!) = (45)(44)(43) COMBINATORICS
Exercise: • Let S = {1, 2, 3}. • How many 2-permutations of S are there? • List all the 2-permutations of S. • Six different people are running for the same office. A preliminary caucus will reduce this number to four candidates before the election. The final ballot will list these four candidates in some fixed random order. How many possible final ballots are there? COMBINATORICS
Selection of objects • How many different 5-card poker hands? • Why not: (52) (51) (50) (49) (48) = P(52,5) ?? • Overcounted: e.g., these hands are the same: In fact, any permutation of these 5 cards results in the same hand (order does not matter!) COMBINATORICS
Selection of objects • Division Rule: If in counting set B every element of A is counted exactly k times, then |A| = k -1|B| • How many different 5-card poker hands? • In counting 5-permutations of 52, how much have we over counted? • Every 5-card hand is counted 5! times COMBINATORICS
Combinations • Definition: an r-combination is an unordered selection of r elements • Definition: C(n,r) (also written ) denotes the number of r-combinations from a set of n distinct elements (i.e., the number of subsets of size k) • Theorem: • Proof: P(n,r) counts each r-combination exactly r! times, so the equation follows from the division rule (and some math facts) COMBINATORICS
Combinations • Theorem: • Another proof: To make an arrangement of rout of n distinct objects, we can • First, select r objects, and then • Arrange theser objects in order. • Thus, P(n,r) = C(n,r) P(r,r) = C(n,r)r! • Other useful identities Can be proved algebraically, but all have intuitive counting proofs, which make good HW & exam questions (good concept questions)! COMBINATORICS
Exercise: Counting “fours-of-a-kind” Fours-of-a-kind: poker hands with • Four cards of the same rank • One card of a different rank COMBINATORICS
Exercise: Counting “fours-of-a-kind” # 4-kind hands = C(13,1)C(48,1) = (13)(48) = 624 COMBINATORICS
Counting “full houses” A full house: 3-of-a-kind & 2-of-a-kind # full houses = # choices for ranks for the triple # choices for their suits # choices for ranks for the pair # choices for their suits = C(13,1) C(4,3) C(12,1) C(4,2) = (13) (4) (12) (6) = 3744 COMBINATORICS
Counting “two pairs” Two pairs: two 2-of-a-kind (different values), 1 other value What’s wrong with this argument? # 2-pairs = # choices for values for one of the pairs # choices for their suits # choices for values for the other of the pairs # choices for their suits # choices for the last card = (13) (6) (12) (6) (44) COMBINATORICS
Counting “two pairs” • Every hand has been counted twice! • Solution? • Use the product (division) rule: # 2-pairs = ((13) (6) (12) (6) (44))/2 • Or, choose the values of the two pair together:# 2-pairs = # choices of two values for the pairs # choices for suits for one of the pair # choices for suits for the other pair # choices for last card = C(13,2) C(4,2) C(4,2) C(44,1) COMBINATORICS
Combinations Subsets of size r Order does not matter No replacement C(n,r): Countingr-permutations counts each r-combination exactly r! times Permutations Arrangements of size r Order matters No replacement P(n,r): Select r items, then arrange the selected items Combinations v.s. Permutations COMBINATORICS
Combinations and the power set • Recall how to count P(A), the power set of a set A, where |A| = n: • So, |P(A)| = |{0, 1}n| = 2n COMBINATORICS
Combinations and the power set Binomial Coefficients COMBINATORICS
Combinations and expanding binomials Binomial Theorem: • Expand: (x + y) (x + y) . . . (x + y) n factors COMBINATORICS
Expanding binomials Choose 0 of 4 factors to contribute a y (x + y)(x + y)(x + y) (x + y) = xxxx + xxxy + xxyx + xyxx + yxxx + xxyy + xyxy + yxxy + xyyx + yxyx + yyxx + xyyy + yxyy + yyxy + yyyx + yyyy = Choose 1 of 4 factors to contribute a y Choose 2 of 4 factors to contribute a y COMBINATORICS
Expanding binomials Choose 0 of 4 factors to contribute a y (x + y)(x + y)(x + y) (x + y) = xxxx + xxxy + xxyx + xyxx + yxxx + xxyy + xyxy + yxxy + xyyx + yxyx + yyxx + xyyy + yxyy + yyxy + yyyx + yyyy = Choose 1 of 4 factors to contribute a y Choose 2 of 4 factors to contribute a y COMBINATORICS
Expanding binomials Expand: (x + y) (x + y) (x + y) What is the coefficient of the xn–kyk term? How many ways to choose k of the n factors to contribute a y (all others contribute an x)? C(n,k) n factors COMBINATORICS
Binomial theorem: finding coefficients • What is the coefficient of w9u11 in the expansion of (3w – 2u)20 ? • Observe: (3w – 2u)20 = ((3w) + (–2u))20 . • So, by the binomial theorem, the terms in this expansion have the form C(20, 20 – k ) (3w)20 – k (-2u)kfor some k, where 0 k n. • The coefficient of the term in question is obtained when k = 11. • Thus, the coefficient is:C(20,9) 39 (-2)11 = – 6.77059928 × 1012 COMBINATORICS
Binomial theorem: Proving identities C(n,0) – C(n,1) + C(n,2) – C(n,3) + + (-1)nC(n,n) = 0 Proof: From the binomial theorem, with x = 1 and y = -1, we have: (1 + -1)n = C(n,0) (1)n-0(-1)0 + C(n,1) (1)n-1 (-1)1 +C(n,2) (1)n-2 (-1)2 + C(n,3) (1)n-3 (-1)3 + + C(n,n) (1)n-n (-1)n = C(n,0) – C(n,1) + C(n,2) – C(n,3) + + (-1)nC(n,n) 0 COMBINATORICS
Pascal’s identity and triangle Pascal’s Identity: Combinatorial Proof: • By definition, the LHS of the equation is the number of k-element subsets of {1, 2, … n}. • Each k-element subset either contains n or not. • # of k-element subsets that do not contain n is C(n – 1, k). • (# of k-element subsets of {1, 2, … n} that contain n) = (# of (k – 1)-element subsets of {1, 2, ..., n – 1}) = C(n – 1, k – 1). • Thus, the identity is proved using the sum rule. COMBINATORICS
Pascal’s Triangle 1 1 1 1 2 1 1 3 3 1 . . . . . . . . . . . . . 1 . . . mn – 1, k – 1mn – 1, k . . . 1 + 1 . . . . . . . . . . . . mn , k . . . . . . . . . 1 Pascal’s identity, together with C(0,0)= C(1,0) = C(0,1) = 1, proves that Pascal’s triangle generates the binomial coefficients! COMBINATORICS
Permutations with Repetition • The number ofr-permutations of a set of n objectswith repetition allowed is nr • Follows directly from the product rule. • Example: How many schedules for featuring a single product on each day of the week can a store manager create if the store sells 2,000 products and it is OK to feature the same item on multiple days? (i.e., assignments of days to featured items) • Choose a product to feature on Monday (2000 ways) • Choose a product to feature on Tuesday (2000 ways) • …. • By the product rule: 20007 = 1.28 1023 COMBINATORICS
Combinations with Repetition • How many ways can you fill a box with videos if the box holds 20 videos, and you have 5 different titles to choose from and an unlimited supply of copies of each of the 5 titles? • Note: Person receiving the box does not care what order the videos are packed into the box; but cares only how many of each title she gets. • 20-combinations with repetition of 5 (types of) objects • We represent each possible combination by a unique string of 20 zeros and 4 ones. • I.e., we demonstrate a bijection between the set of binary strings of length 24 containing 20 zeros and 4 ones and the 20-combinations • Thus proving that there are C(24,4) or, equivalently, C(24,20) ways to pack the box. COMBINATORICS
Combinations with Repetition • To represent each possible outcome by a unique string of 20 zeros and 4 ones, we use the 4 ones as “dividers” and the 20 zeros to represent videos • The zeros before first divider (if any) are Title#1, the zeros between 1st and 2nd (if any) are Title#2, etc. • Why 4 dividers? Because there are 5 titles and the 1’s are used as separators. 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0110 0 0 0 0 0 COMBINATORICS
Combinations with Repetition • The number of r-combinations from a set of n elements, if repetition of elements is allowed, is C(n + r – 1, r). • The proof mimics previous example: Each r-combination can be represented by a binary string of length n + r – 1 containing exactly r zeros and n – 1 ones. objects inthe combination markers to keeptrack of repeatedobjects COMBINATORICS
Exercise • How many ways are there to choose a dozen bagels from a shop that sells 5 varieties of bagels: onion, pumpernickel, poppy seed, plain, and salt? • Represent an order of 12 bagels by a bit string of length 16 (12 + 5 − 1) containing four 1’s and twelve 0’s. • For example, “1100000100010000” represents an order with 0 onion, 0 pumpernickel, 5 poppy, 3 plain, and 4 salt bagels. • To count the number of such strings: Choose 4 of the 16 locations to fill with a 1 and fill the rest with a 0. • Hence, there are C(16, 4) possible orders that the store could fill for a dozen bagels. COMBINATORICS
Non-negative integer solutions to summation equations • How many non-negative integers solutions are there to the equation x1 + x2 + x3 + x4 = 101 ? • A solution corresponds to a selection of 101 items from 4 different types of objects, where • x1 denotes the number of type 1 items selected • x2 denotes the number of type 2 items selected • x3 denotes the number of type 3 items selected • x4 denotes the number of type 4 items selected • A selection of 101 items of up to 4 different types of items corresponds to a binary string of length 104 (101 + 4 – 1) containing exactly 3 ones • Thus, there are C(104,3) = (104103102)/3! = 182104 solutions COMBINATORICS
Exercise • How many non-negative integer solutions are there to the equation a + b + c = 10 ? • Represent a solution by a bit string of length 12 (10+3−1) containing exactly two 1’s (and ten 0’s) • For example: “110000000000” represents a = 0, b = 0, c = 10“001001000000” represents a = 2, b = 2, c = 6… • To construct such a string: Choose 2 of 12 positions to fill with a 1; fill the remaining 10 positions with 0’s. • C(12,2) possible solutions COMBINATORICS
Permutations with Indistinguishable Objects • How many different 15-digit serial numbers are there containing exactly 3 zeros, 4 ones, 2 twos, and6 threes? (e.g., 001123332101333, etc.) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ • Choose 3 of the 15 spots for the zeros • C(15,3) ways • Choose 4 of the remaining 12 spots for the ones • C(12, 4) ways • Choose 2 of the remaining 8 spots for the twos • C(8, 2) ways • Choose 6 of the remaining 6 spots for the threes • C(6, 6) ways • Product rule: C(15,3) C(12, 4) C(8, 2) C(6, 6) ways COMBINATORICS
Permutations with Indistinguishable Objects • The number of different permutations (arrangements) ofn objects where there are n1 indistinguishable objects of type 1, n2 indistinguishable objects of type 2, …, and nk indistinguishable objects of type k and where n = n1 + n2 + nk, is C(n, n1) C(n n1, n2) C(n n1 n2, n3) C(n n1 n2 nk-1, nk) = COMBINATORICS
Exercise • How many different strings can be made by reordering the letters of the word: AARDVARK • The word will be 8 letters long • Choose 3 of the 8 positions to fill with A’s’ • Choose 2 of the 5 remaining positions to fill with R’s • Choose 1 of the 3 remaining positions to fill with a D • Choose 1 of the 2 remaining positions to fill with a K • Choose 1 of the remaining 1 positions to fill with a V C(8,3) C(5,2) C(3,1) C(2,1) C(1,1) = ((876)/3!)((54)/2!)(3)(2)(1) = 4480 Alternately: arrange the D, K, V and fill them, as arranged, into the remaining 3 positions (3! ways) COMBINATORICS
. . . . . . . . . player 1 player 2 player 3 player 4 rest of deck Exercise: Distributing Objects into Boxes • How many ways are there to deal 5 cards to each of 4 players from the standard deck of 52 playing cards? How to distribute 52 distinguishable objects (cards) into 5 boxes (4 players and rest pile), such that the first 4 boxes each get 5 objects and last box gets 32 COMBINATORICS
Distributing Objects into Boxes (Exercise) • Choose 5 of 52 cards to deal to player 1 • Choose 5 of the remaining 47 cards to deal to player 2 • Choose 5 of the remaining 42 cards to deal to player 3 • Choose 5 of the remaining 37 cards to deal to player 4 • C(52,5) C(47,5) C(42,5) C(37,5) . . . . . . . . . player 1 player 2 player 3 player 4 rest of deck COMBINATORICS
Distributing Objects into Boxes • The number of ways to distribute n distinguishable objects into k distinguishable boxes so that ni objects are placed into box i, for i = 1, 2, …, k, is C(n, n1) C(n −n1, n2) C(n −n1 − n2, n3) C(n −n1 − n2 −nk-1, nk) = COMBINATORICS
Exercise • How many ways can n indistinguishable books be placed on k distinguishable shelves? • Only care about the number on each of the shelves: a problem of distributing n books among k shelves. • Represent an outcome by a bit string of length n + k − 1 containing exactly n 0’s: C(n + k − 1, n) • How many ways can n books be placed on k distinguishable shelves if no two books are the same? • Here, we care about the books on each shelf and how they are ordered. • Represent an outcome by an arrangement of the n books into which you have inserted k − 1 dividers: n! C(n + k − 1, k − 1) COMBINATORICS
Sources for these slides include • MIT Open Courseware, Mathematics for Computer Science (SMA 5512) http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-042JMathematics-for-Computer-ScienceFall2002/Calendar/index.htm • Stat 134, University of California, Berkeley, http://www.stat.berkeley.edu/~mossel/teach/134f06/index.htm • Discrete Mathematics and Its Applications, Kenneth Rosen • Previous offerings CSE 260, Michigan State University COMBINATORICS