Discrete MathematicsCounting: Choices, Arrangements and Selections1 of 7
Counting: Choices, Arrangements and Selections · 1
The Sum and Product Rules
We want to count how many ways an outcome can happen without listing every possibility by hand, and the main decision is when to multiply our choices and when to add them.
1
The Product Rule and Slots
Suppose you have 3 shirts (A, B, C) and 4 pairs of pants (1,2,3,4) and want to find how many different outfits you can make, or you have 5 people (A, B, C, D, E) and want to find how many ways to pick a President and a Vice President when nobody can hold both jobs.
The Product Rule and Slots
Text solution
Pair each shirt with each pair of pantsPicking an outfit from a set S of 3 shirts and a set P of 4 pairs of pants means forming an ordered pair (s,p)∈S×P, where each of the 3 shirt branches splits into 4 pants branches.
Fill the President and Vice President slotsAny of the 5 people can be chosen as President first, and regardless of who wins, 4 people remain for Vice President on every branch.
Pres050×VP040=20 ways
2
The Sum Rule and Uneven Trees
When a slot has a restriction, filling slots from left to right can use up some of the allowed options early and leave different numbers of choices on different branches. Let's find how many 3-digit even numbers we can make from {1,2,3,4,5} with no repeats allowed.
The Sum Rule and Uneven Trees
We can keep the tree uniform by filling the restricted slot first, or we can split the uneven left-to-right tree into separate cases where each piece is uniform.
Text solution
Method 1: Fill the restricted even slot firstLock one of the two even digits (2 or 4) into the 3rd slot first so that every branch has 4 remaining digits for the 1st slot and 3 for the 2nd slot.
1st040×2nd030×3rd (even)fill 1st020=24 even numbers
Method 2: Split by whether the 1st digit is even or oddIf the 1st digit is even (2 or 4), only 1 even digit remains for the 3rd slot; if the 1st digit is odd (1,3, or 5), both even digits remain open for the 3rd slot.
Add the non-overlapping casesEvery 3-digit even number starts with either an even digit or an odd digit, so the two cases have no overlap.
6+18=24 even numbers
See how filling the restricted 3rd digit first keeps the tree uniform, while saving it for last splits the tree unevenly:
Filling the restricted even slot first keeps every step splitting evenly, while saving it for later forces the tree into separate cases.
3
Overlapping Cases
Adding cases directly only works when the cases cannot happen at the same time. Let's find how many 2-digit codes made from {1,2,3,4} (with repeats allowed) start with 1 OR end with 4.
Overlapping Cases
Text solution
Count each condition on its ownLocking 1 into the 1st slot leaves 4 choices for the 2nd slot (11,12,13,14), and locking 4 into the 2nd slot leaves 4 choices for the 1st slot (14,24,34,44).
starts with 1010×040=4,ends with 4040×010=4
Subtract the doubly-counted overlap onceBecause the code 14 both starts with 1 and ends with 4, adding the two counts includes 14 twice.
starts with 14+ends with 44−both (14)1=7 codes
On the 4×4 grid of all 16 two-digit codes, two rules that restrict the same slot highlight separate strips that add to 4+4=8, whereas restricting different slots highlights a row and a column that cross at one doubly-counted code, giving 4+4−1=7.
Two rules joined by OR stay separate when they check the same digit, and cross at one shared code when they check different digits.
4
Counting Functions with General m and n
The same slot method works when concrete numbers are replaced by general set sizes m and n. Given a starting set A with ∣A∣=m elements and a target set B with ∣B∣=n elements, we want to find how many functions f:A→B exist in total, and how many of them are one-to-one.
Counting Functions with General m and n
Text solution
Count all functions f:A→B (repeats allowed)Each of the m elements in A must send out one arrow, creating m slots, and each arrow can land on any of the n targets in B.
m slots (one for each element in A)0n0×0n0×⋯×0n0=nm functions
Count one-to-one functions f:A→B (no shared targets)Each arrow uses up one target in B, so by the time the m-th element of A picks a target, the previous m−1 elements have taken m−1 targets, leaving n−(m−1)=n−m+1 choices (and the product is 0 whenever m>n, because the (n+1)-th slot has 0 choices).
Watch how the n target choices in B stay open in every slot for general functions, and step down by 1 after each arrow for one-to-one functions:
Each element in the starting set opens a slot of choices from the target set, and locking out shared targets drops the choices by one at each step no matter which targets were taken earlier.
Key concepts
Every counting problem here comes down to how the choices branch as you build an outcome step by step:
Sequence of decisions with uniform branch counts (Product Rule)
When you make a sequence of choices to build one complete result, draw one slot per decision, fill the most restricted slots first, and multiply the number of choices. For 3-digit even numbers from {1,2,3,4,5} without repeats, filling the even 3rd slot first gives 4×3×2=24. Do not split into cases just because the specific options left over change from branch to branch: as long as the number of remaining options is the same on every branch (like 5×4=20 for President and Vice President), you can multiply in one step.
Uneven trees where an earlier choice changes later counts (Sum Rule)
When a restriction makes the number of remaining choices depend on which option was picked earlier, split the problem at that choice into separate, non-overlapping cases, multiply the slots inside each case, and add the cases together (for those same 3-digit even numbers split by the 1st digit: 2×3×1+3×3×2=6+18=24).
Overlapping "OR" cases
If an outcome can satisfy both cases at the same time, adding the cases counts that overlap twice, so subtract the overlap once (for 2-digit codes from {1,2,3,4} starting with 1 OR ending with 4:1×4+4×1−1=7, subtracting the code 14).
Functions f:A→B with ∣A∣=m and ∣B∣=n
Draw m slots (one for each element in A) and fill them with target choices from B:
All functions: m slotsn×n×⋯×n=nm,One-to-one (m≤n): n(n−1)(n−2)⋯(n−m+1)
5
Practice
1
A license code consists of 2 letters chosen from {A, B, C, D, E} followed by 3 digits chosen from {1,2,3,4,5,6}. Letters may be repeated, but no digit may be repeated. How many such license codes are possible?
The letter slots have 5 and 5 choices because repeats are allowed (dropping the second letter slot to 4 would forbid repeats and give 2,400), and the digit slots have 6,5, and 4 choices because no digit may be repeated.Because choosing the letters and choosing the digits are back-to-back steps to build a single code, multiply the slots rather than adding the 25 letter pairs and 120 digit triples (adding gives 145).
Draw 5 slots for the 2 letters and 3 digits: which slots keep the same number of choices, and which slots drop by 1 each step?
Draw 5 slots (2 for letters, 3 for digits). The letter slots have 5 and 5 choices because repeats are allowed (dropping the second letter slot to 4 would forbid repeats and give 2,400), and the digit slots have 6,5, and 4 choices because no digit may be repeated. Because choosing the letters and choosing the digits are back-to-back steps to build a single code, multiply the slots rather than adding the 25 letter pairs and 120 digit triples (adding gives 145):
5×5×6×5×4=3,000
2
How many 4-letter codes can be formed from the letters {A, B, C, D, E, F} without repeats if the first letter must be a vowel (A or E) and the last letter must be a consonant (B, C, D, or F)?
Because vowels and consonants do not overlap, picking a vowel for the 1st slot never uses up a consonant (reducing the 4th slot to 3 choices gives the wrong answer 72).
Fill the 1st and 4th slots before the middle slots: can a vowel chosen for the 1st slot ever use up one of the consonants needed for the 4th slot?
Fill the two restricted slots first: there are 2 choices for the 1st slot (A or E) and 4 choices for the 4th slot (B, C, D, or F). Because vowels and consonants do not overlap, picking a vowel for the 1st slot never uses up a consonant (reducing the 4th slot to 3 choices gives the wrong answer 72). Locking in those two end slots uses 2 of the 6 letters, leaving 4 choices for the 2nd slot and 3 choices for the 3rd slot:
2×4×3×4=96
3
Using only the digits {0,1,2,3,4,5} with no repeats allowed, how many 3-digit even numbers can be formed? (A 3-digit number cannot start with 0.)
Because 0 is an even digit (allowed in the 3rd slot) and also forbidden in the 1st slot, the number of choices for the 1st slot depends on whether 0 was used in the 3rd slot, so you cannot multiply in a single step as 4×4×3=48 or 5×4×3=60.
Both the 1st slot (cannot be 0) and the 3rd slot (must be 0,2, or 4) are restricted, and 0 belongs to both rules: how does the number of choices for the 1st slot change depending on whether the 3rd slot is 0 or not?
Because 0 is an even digit (allowed in the 3rd slot) and also forbidden in the 1st slot, the number of choices for the 1st slot depends on whether 0 was used in the 3rd slot, so you cannot multiply in a single step as 4×4×3=48 or 5×4×3=60. Split into two non-overlapping cases based on the 3rd digit:
Case 1 (3rd digit is 0)1 choice for the 3rd slot (0), 5 choices for the 1st slot (any of 1,2,3,4,5), and 4 remaining choices for the 2nd slot, giving 5×4×1=20.
Case 2 (3rd digit is 2 or 4)2 choices for the 3rd slot (2 or 4), and 4 choices for the 1st slot (cannot be 0 or the chosen 3rd digit). For the 2nd slot, 0 is available again, so 4 of the 6 digits remain (forgetting that 0 can go in the middle slot leaves 3 choices and gives 24 instead of 32): 4×4×2=32. By the Sum Rule:
20+32=52
4
Using the digits {1,2,3,4,5} with no repeats allowed, how many 3-digit numbers either start with an odd digit OR end with an even digit?
Do not stop at 36+24=60, which counts the 18 overlapping numbers twice; subtract the overlap once.
Count the numbers that start with an odd digit and the numbers that end with an even digit, then check whether a 3-digit number can do both at the same time.
Starts with an odd digit (1,3, or 5)3×4×3=36.
Ends with an even digit (2 or 4)Fill the 3rd slot first with 2 choices, leaving 4 for the 1st slot and 3 for the 2nd: 4×3×2=24.
Overlap (starts with an odd digit AND ends with an even digit)3 odd choices for the 1st slot, 2 even choices for the 3rd slot (since no even digit was used first), and 3 remaining digits for the 2nd slot: 3×3×2=18. Do not stop at 36+24=60, which counts the 18 overlapping numbers twice; subtract the overlap once:
36+24−18=42
5
Let A={a1,a2,a3,a4} and B={b1,b2,b3,b4,b5,b6}.
(a) How many functions f:A→B satisfy f(a1)=b1?
(b) How many one-to-one functions f:A→B satisfy f(a1)=b1?
(c) In general, if ∣A∣=m and ∣B∣=n with 1≤m≤n, how many one-to-one functions f:A→B satisfy f(a1)=b1?
Because a general function allows repeated targets, a2,a3, and a4 still have all 6 choices in B (dropping b1 to give 1×5×5×5=125 or stepping down as 1×5×4×3=60 wrongly restricts repeats).
Draw one slot for each element of A and fill the restricted slot a1 first; in (b), once a1 picks a target other than b1, is b1 allowed as a target for a2,a3, and a4?
(a)Draw 4 slots for a1,a2,a3,a4. The 1st slot (a1) has 1 choice (b1). Because a general function allows repeated targets, a2,a3, and a4 still have all 6 choices in B (dropping b1 to give 1×5×5×5=125 or stepping down as 1×5×4×3=60 wrongly restricts repeats):
1×6×6×6=63=216
(b)Fill the restricted slot a1 first: a1 has 5 choices (anything in B except b1). For a2,b1 is now available again while a1's chosen target is taken, leaving 5 choices for a2, then 4 for a3, and 3 for a4 (stepping straight down from 5 as 5×4×3×2=120 forgets that b1 is available again for a2):
5×5×4×3=300
(c)Draw m slots for a1,…,am. The 1st slot (a1) has 1 choice (b1), and the remaining m−1 elements of A map one-to-one into the remaining n−1 elements of B. By the m-th slot, m−1 targets have been taken, so the last factor is n−(m−1)=n−m+1 (writing n−m subtracts one target too many):