The Basics of Counting
Counting problems arise when we want to know how many ways something can be done, without listing every possibility. They are built on a few simple counting principles.
The Product Rule
Def
Suppose that a procedure can be broken down into a sequence of two tasks. If there are
ways to do the procedure.
The product rule applies when a task is made of successive steps, and the choices for each step do not depend on which choices were made before (only the count matters).
Extended to a sequence of tasks
- Example:
- A license plate has
letters followed by digits. - Letters:
choices each, digits: choices each. - Total
.
- A license plate has
Set form
If Cartesian product is the product of their sizes:
The Sum Rule
Def
If a task can be done either in one of
ways to do the task.
The sum rule applies when we choose from disjoint alternatives — exactly one of the groups is used, and the groups share no options.
Extended to tasks
- Example:
- A student picks one project from
math topics or CS topics. - The two lists have no topic in common.
- Total
choices.
- A student picks one project from
Set form
If
WARNING
The sum rule requires the alternatives to be disjoint. If the groups overlap, simply adding their sizes double counts the shared options — use the subtraction rule instead.
The Subtraction Rule
Also known as the Inclusion–Exclusion principle for two sets.
Def
If a task can be done in either
where
We add the sizes of the two groups, then subtract the overlap once, because elements in both groups were counted twice.
Set form
For any two finite sets
- Example:
- How many bit strings of length
either start with a or end with ? - Start with
: . - End with
: . - Both (start with
and end with ): . - Total
.
- How many bit strings of length
The Division Rule
Def
There are
The division rule applies when a straightforward count produces each outcome d times. Dividing by
Set form
If a finite set
- Example:
- How many different ways can
people be seated around a circular table, where two seatings are the same when each person has the same left and right neighbor? - In a row there are
orderings. - Each circular arrangement corresponds to
rotations of the same seating. - Total
.
- How many different ways can
Intuition
| Rule | When to use | Combine by |
|---|---|---|
| Product | A sequence of independent steps (do this and then this) | |
| Sum | Disjoint alternatives (do this or this) | |
| Subtraction | Alternatives that overlap | |
| Division | A count where each outcome appears |