mindstair

Home / Courses / Discrete Mathematics / Unit 4

Discrete Mathematics Unit 4: Counting

Counting answers "how many ways?" without listing them. Decide whether order matters and whether repetition is allowed.

Covers: Sum & product rules, permutations, combinations, pigeonhole principle, inclusion-exclusion

Study guide

Counting problems ask how many ways something can happen. The sum rule says that if a task can be done in one of m ways or one of n other ways (with no overlap), there are m + n options. The product rule says that if a procedure has a step with m ways followed by a step with n ways, there are m·n total. Most counting problems combine these.

A permutation is an ordered arrangement. The number of ways to arrange r of n distinct items is P(n, r) = n!/(n − r)!, and all n items can be arranged n! ways. Arrangements of letters with repeats divide by the factorials of the repeat counts.

A combination is an unordered selection: C(n, r) = n!/(r!(n − r)!). Ask whether order matters; if swapping two chosen items gives the same outcome, use combinations. With repetition allowed and order not mattering, stars and bars gives C(n + r − 1, r).

The pigeonhole principle says that if n + 1 objects go into n boxes, some box holds at least two. The generalized version says some box holds at least ⌈N/k⌉. It proves existence without finding the specific example.

Inclusion–exclusion counts unions with overlap: |A ∪ B| = |A| + |B| − |A ∩ B|, and for three sets add back the triple intersection. Complementary counting (total minus the unwanted cases) is often easier for "at least one" problems.

The number of functions from an m-element set to an n-element set is nᵐ. The number of injections is P(n, m) = n!/(n − m)! (zero if m > n), and the number of bijections between two n-element sets is n!. The division rule says that if each outcome is counted exactly k times, divide the total by k. For example, dealing 52 cards into 13-card hands for four players, where order within a hand doesn't matter, can be counted as 52! arrangements divided by (13!)⁴.

Key ideas

Formulas and rules

P(n, r) = n!/(n − r)!
C(n, r) = n!/(r!(n − r)!)
Repetition allowed, order doesn't matter: C(n + r − 1, r)

Common mistakes

Words to know

Permutations P(n, r)
n!/(n − r)!
Combinations C(n, r)
n!/(r!(n − r)!)
Pigeonhole principle
Putting n + 1 objects into n boxes forces some box to hold at least 2.
Order matters vs. doesn't
Order matters: permutations. Order doesn't: combinations.
Stars and bars: choosing r items from n types with repetition
C(n + r − 1, r)
Sum rule
m or n ways (no overlap) gives m + n.
Product rule
m ways then n ways gives m·n.
Permutations with repeated letters
n!/(n₁!n₂!…)
Generalized pigeonhole principle
N objects in k boxes force a box with at least ⌈N/k⌉.
Inclusion–exclusion
|A ∪ B| = |A| + |B| − |A ∩ B|
Complementary counting
Total minus the unwanted cases.

Sample practice questions

29 more questions like these, from level 1 to 5, are in the practice set.

Question 1 (level 1)

Outfits from 3 shirts and 4 pants.

  1. 64
  2. 7
  3. 12
  4. 81
Show the answer and steps

Answer: C) 12

  1. Product rule: 3 shirts × 4 pants.
  2. 12.
Question 2 (level 1)

A meal has 3 mains, 2 sides and 4 drinks. How many different meals with one of each?

  1. 24
  2. 48
  3. 10
  4. 9
Show the answer and steps

Answer: A) 24

  1. Product rule: multiply the number of choices.
  2. 3 × 2 × 4 = 24.
Question 3 (level 3)

Ways to choose 2 people from 6.

  1. 12
  2. 30
  3. 36
  4. 15
Show the answer and steps

Answer: D) 15

  1. C(6, 2) = 6!/(2!·4!).
  2. = 15.