Elementary Counting Techniques & Combinatorics
Combinatorics • the branch of discrete mathematics concerned with determining the size of finite sets without actually enumerating each element.
Combinatorics • The Sum Rule (task formulation): – Suppose that a task can be completed by performing exactly one task from a collection of disjoint subtasks: subtask1, subtask2, ... , subtaskn; – Now suppose each subtask has a choice of ways to perform it, e.g. • • • •
subtask1 can be performed t1 ways, subtask2 can be performed t2 ways, ... subtaskn can be performed tn ways.
– Then number the number of ways to perform the task is:
t1 + t2 + ... + tn
The Sum Rule • Example: – Suppose either a CS faculty or a CS student must be chosen for a committee, and there are 4 CS faculty and 16 CS students. How many possible choices are there?
Combinatorics • The Product Rule (task formulation): – Suppose a task needs to be done, and the tasks consists of a sequence of n steps or subtasks: task = task1, task2, task3, ..., taskn where each task taskx has a certain number of ways (tx) in which it can be performed after the preceding tasks have been performed, e.g. • • • •
task1 = t1 ways, task2 = t2 ways after task1 is complete, task3 = t3 ways after task1 and task2 is complete, ... , taskn = tn ways after task1 ... taskn-1 is complete
Then the number of ways the task can be performed is: t1 t2 t3 ... tn
Example - Product Rule • How many different ways can we chose from 4 colors and paint 3 rooms? – Tasks: • 1 - paint room 1 - 4 ways to perform (4 colors) • 2 - paint room 2 - 4 ways to perform (4 colors) • 3 - paint room 3 - 4 ways to perform (4 colors)
– Thus t1 = 4, t2 = 4, t3 = 4, and 4 4 4 = 64 ways to paint the rooms
Example - Product Rule • How many different ways can we chose from 4 colors and paint 3 rooms, if no room is to be the same color? – tasks: • 1 - paint room 1 - 4 ways to perform (4 colors) • 2 - paint room 2 - 3 ways to perform (3 colors left) • 3 - paint room 3 - 2 ways to perform (2 colors left)
– Thus t1 = 4, t2 = 3, t3 = 2, and 4 3 2 = 24 ways to paint the rooms
Example - Product Rule • How many different orders may 9 people be arranged in? – There are nine tasks - picking the first person, picking the second, … – The first task has 9 choices, the second 8, ... and finally the ninth task has 1 choice:
9 8 7 6 5 4 3 2 1 = 362880
Combinatorics • The Product Rule (set formulation): – If A and B are finite sets, then:
|A B| = |A| |B| – The cardinality of the Cartesian product of two sets is the product of the their cardinalities. – Note that ANY ordered list of items is trivially equivalent to a Cartesian product.
Example - Product Rule Let A = {a, b, c, d, e}, B = {1, 3, 5, 7} • How many pairs (x, y) exist where x A and y B? • A B has cardinality |A| |B| = 5 4 = 20
Example - Product Rule • How many license plates are possible with 3 uppercase letters followed by 3 digits? 262626101010 = 17576000
Combinatorics • The Sum Rule (set formulation): If A and B are disjoint finite sets, then: |A B| = |A| + |B| The cardinality of the union of two disjoint sets is the sum of their cardinalities.
Example - The Sum Rule Let A = {a, b, c, d, e}, B = {1, 3, 5, 7} • How many ways can one element be chosen?
|A B| = |A| + |B| = 5 + 4 = 9.
The Pigeonhole Principle • If k + 1 or more objects are placed in k boxes, then there is at least one box containing two or more objects.
The Pigeonhole Principle • If k + 1 or more objects are placed in k boxes, then there is at least one box containing two or more objects.
The Pigeonhole Principle • If k + 1 or more objects are placed in k boxes, then there is at least one box containing two or more objects.
The Pigeonhole Principle • If k + 1 or more objects are placed in k boxes, then there is at least one box containing two or more objects. • Proof: Suppose that none of the k boxes contains more then one object. Then the maximum number of objects would be k. This is a contradiction, since there is at least k + 1 objects.
The Pigeonhole Principle • The Generalized Pigeonhole Principle: If N objects are placed into k boxes, then there is at least one box containing at least N/k objects.
Generalized Pigeonhole Principle • If N objects are placed into k boxes, then there is at least one box containing at least N/k objects.
Generalized Pigeonhole Principle • If N objects are placed into k boxes, then there is at least one box containing at least N/k objects.
Generalized Pigeonhole Principle • If N objects are placed into k boxes, then there is at least one box containing at least N/k objects.
Generalized Pigeonhole Principle • Proof: Suppose that none of the boxes contains more than N/k - 1 objects. Then the total number of objects is at most: k (N/k - 1). But since N/k < (N/k + 1), we get the following: k (N/k - 1) < k (((N/k + 1) - 1) = N, thus k (N/k - 1) < N which is a contradiction since there is a total of N objects.
Generalized Pigeonhole Principle • Among 100 people there are at least 100/12 = 9 people with the same birthday month.
Generalized Pigeonhole Principle • In a class of 44 students, how many will receive the same grade on a scale {A, A-, B, B-, C, C-, D, E}.
Permutations and Combinations • Consider: How many ways can we choose r things from a collection of n things?
pick
Pick 4 from 9 colored balls
Permutations and Combinations • Consider: How many ways can we choose r things from a collection of n things? • This statement is ambiguous in several ways: – Are the n things distinct or indistinguishable? – Do the selected items form a set (unordered collection) or a sequence (ordered)? – May the same item be selected from the r items more then once? (Are repetitions permitted?).
Permutations and Combinations • Example using balls: – Are the balls identical or different colors? Are some different colors, others the same? – Are balls tossed in a bucket (unordered) or lined up in a line in the order chosen? – Each ball returned to the collection before the next is selected?
Permutation • An ordered selection of objects. • If there is a collection of n objects to chose from, and we are selecting all n objects, then we call each possible selection a permutation from the collection. • In the general case the items are all distinct, and repetitions are not permitted.
Permutation • Possible permutations of three colored balls:
Permutation • Consider the set S = {a, b}. What are the permutations?
ab ba
Permutation • Consider the set S = {a, b, c}. What are the permutations?
abc acb bca bac cab cba
Permutation • Consider the set S = {a, b, c, d}. What are the permutations?
abcd abdc adbc dabc
acbd acdb adcb dacb
bcad bcda bdca dbca
bacd badc bdac dbac
cabd cadb cdab dcab
cbad cbda cdba dcba
Permutation • Theorem: The number of permutations of a set of n objects is the product of the first n positive integers, that is n(n -1) ... 1 = n = n!
Permutation Justification: Arranging n objects into order requires n tasks. Task 1 Pick first object (n choices) Task 2 Pick second object (n-1 choices) ... Task n Pick last (nth) object (1 choice)
Thus, by the product rule, the number of ways to arrange n objects is:
n(n -1) ... 1 = n!
r-Permutations • Consider ordering a subset of a collection of objects. • If there is a collection of n objects to chose from, and we are selecting r of the objects, where 0
r-Permutations • Consider a 4-permutation of 9 balls
pick
r-Permutations Consider the set S = {a, b, c}. • What are the 2-permutations of S?
ab ba ac ca bc cb • What are the 3-permutations of S?
abc acb bca bac cab cba
r-Permutations Consider the set S = {a, b, c, d}. • What are the 2-permutations of S?
ab ac ad ba bc bd ca cb cd da db dc
r-Permutations Consider the set S = {a, b, c, d}. • What are the 3-permutations of S? abc acb bac bca cba cab (from {a, b, c}) abd adb bad bda dba dab (from {a, b, d}) adc acd dac dca cda cad (from {a, c, d}) dbc dcb bdc bcd cbd cdb (from {b, c, d})
r-Permutations • Theorem: The number of r-permutations of a set of n objects, written P(n, r) is:
n! P(n, r ) n(n-1) ... (n-r 1) (n r )!
r-Permutations • Justification: – Arranging r of n objects into order requires r tasks. Task 1 Pick first object (n choices) Task 2 Pick second object (n-1 choices) … Task r Pick rth object (n - r + 1 choices)
– Thus, by the product rule, the number of ways to arrange n objects is:
n! n(n-1) ... (n-r 1) (n r )!
r-Permutations Consider a horse race with 8 horses. • If a spectator were select three different horses at random to bet on for first, second and third places, how likely is he to be completely correct? • P(8,3) = 8 7 6 = 336 permutations possible • Thus he has a 1 in 336 chance.
Combinations • Combination - an unordered selection of objects. • Definition:
–Consider a set S with n objects. Every k sized subset of those objects (0
Combinations Consider the set A = {a, b, c}. • What are the 2-combinations of A?
{a, b} {a, c} {b, c} • What are the 3-combinations of A?
{a, b, c} • What are the 1-combinations of A?
{a} {b} {c}
Combinations Consider the set B = {a, b, c, d}. • What are the 2- combinations of B? {a, b} {a, c} {a,d} {b, c} {b, d} {c, d} • What are the 3-combinations of B? {a, b, c} {a, c, d} {b, c, d} {a, b, d}
Combinations • Notice the comparison of 3-combinations of B with 3-permutations: 3-permutations 3-combinations abc acb bac bca cba cab {a, b, c} abd adb bad bda dba dab {a, b, d} adc acd dac dca cda cad {a, c, d} dbc dcb bdc bcd cbd cdb {b, c, d}
Combinations • This shows that each r-combination has r-permutations possible. Thus the following theorem: • Theorem: The number of r -combinations of a set of n distinct objects is:
P(n, r ) n! C (n, k ) r! r!(n r )!
Combinations P(n, r ) n! C (n, k ) r! r!(n r )! – Justification: We find the number of permutations, then divide by a factor which we have overcounted. Since each r-combination of the n objects can be ordered P(r,r) = r! ways, we divide the number of r-permutations from n objects by the number of r-permutations of r objects.
Combinations • The number C(n,r) is also written:
n C (n, r ) r • And is be read n choose r objects.