maths.free › Discrete Math & Logic › Counting: rules, choices and bijections
Counting: rules, choices and bijections
The sum and product rules, permutations and combinations, stars and bars, and counting one set by matching it with another.
Two rules carry most of counting. The sum rule: if a choice can be made in one of several disjoint ways, the counts add. The product rule: if a choice is a sequence of steps, and step \( i \) can be done in \( n_i \) ways whatever happened before, the counts multiply. A licence plate of three letters then three digits can be filled in \( 26^3 \cdot 10^3 \) ways. The number of arrangements of \( k \) of \( n \) distinct objects in order is \( n(n-1)\cdots(n-k+1) = n!/(n-k)! \).
When order does not matter, each unordered selection has been counted once for every one of its \( k! \) orderings, so the number of combinations is \[ \binom{n}{k} = \frac{n!}{k!\,(n-k)!}. \] The example chooses 3 from 10 in \( \binom{10}{3} = 120 \) ways. Dividing out an overcount like this is a basic technique: if every object of interest is counted exactly \( d \) times, divide the total by \( d \).
A bijective proof counts a set by pairing its elements perfectly with those of a set already counted. Choosing which 3 of 10 people are on a committee is the same as choosing which 7 are not, so \( \binom{10}{3} = \binom{10}{7} \). Subsets of an \( n \)-element set correspond to binary strings of length \( n \) (a 1 in position \( i \) means element \( i \) is in), so there are \( 2^n \) of them. And the number of ways to write \( n \) as an ordered sum of \( k \) non-negative integers, \( x_1 + \dots + x_k = n \), matches arrangements of \( n \) stars and \( k - 1 \) bars in a row, which gives stars and bars: \( \binom{n + k - 1}{k - 1} \) solutions.
Double counting is the sibling technique: count one set in two different ways and equate the answers. Counting pairs (a committee of \( k \) from \( n \) people, a chair within it) first by committee then by chair gives \( k\binom{n}{k} = n\binom{n-1}{k-1} \). Counting all subsets by size gives \( \sum_k \binom{n}{k} = 2^n \).
Picture it: lay out the objects to be counted in a grid, one row per first choice and one column per second choice: the product rule is the area of the rectangle. A bijection is a set of strings tying each object in one pile to exactly one object in another, with none left over on either side.
Think it: before multiplying, ask whether order matters and whether repetition is allowed; the four answers give \( n^k \), \( n!/(n-k)! \), \( \binom{n}{k} \) and \( \binom{n+k-1}{k} \). When a direct count is awkward, count the complement, or find a bijection to something easier.
Worked example · how many ways to choose 3 from 10
Step by step
- \binom{10}{3} = \frac{10!}{3!\,(10-3)!}
Unordered selections: n! / (k! (n−k)!).
- = \frac{3628800}{6 \times 5040} = 120
Reveal the answer
Now you Pick a problem, or type or draw your own. Every step, a picture, the answer hidden until you ask.
Symbols used here
Tap any symbol for the full definition, a picture, and what every letter in it means.
How to: Counting: rules, choices and bijections
- Decide whether order matters and whether repetition is allowed.
- Break the choice into steps (product rule) or disjoint cases (sum rule).
- If each outcome is counted d times, divide by d.
- If a direct count is hard, count the complement or build a bijection with a known set.
- Sanity check with a small case you can list by hand.
Questions people ask
Why is 0! equal to 1?
There is exactly one way to arrange no objects (do nothing), and 0! = 1 is also what makes n!/(k!(n - k)!) give 1 for choosing all or none of n objects.
When should I use the complement?
When the condition is "at least one": the number of outcomes with at least one special feature is the total minus the number with none, and "none" is usually a single product.
What makes mathematics "discrete"?
It deals with separate, countable objects (integers, graphs, statements) rather than continuous quantities. No limits, no infinitesimals; instead induction, counting and logic.
How does a proof by induction work?
Show the statement for the first case, then show that whenever it holds for n it holds for n + 1. Like dominoes: the first falls, and each knocks over the next.
What order should I take these lessons in?
Logic and proof first, because every later lesson proves things. Then induction, sets, relations and functions, counting, recurrences, graphs, Boolean algebra and automata, and finally algorithms and complexity, which use nearly everything before them.
Is discrete mathematics the same as the maths of computer science?
Largely. Data structures are graphs and trees, correctness arguments are induction, running times are recurrences and sums, circuits are Boolean algebra, and what a computer can do efficiently is the subject of the last lessons. It is also ordinary mathematics in its own right.
Do I need calculus for this course?
No. School algebra is enough. A little familiarity with limits helps when comparing growth rates, and the lesson on asymptotic analysis explains the one limit fact it uses.
More in Discrete Math & Logic
Truth tablesSums and inductionProof by inductionAlgorithms and growth of functionsPredicate logic and quantifiersDirect proof, contrapositive and contradictionStrong induction and the well-ordering principleRelations: equivalence relations and partial ordersFunctions and cardinalityThe pigeonhole principleSolving linear recurrence relationsGraphs: degrees, paths and connectivityTrees and spanning treesEuler and Hamilton paths