CombinatoricsTopic #15 of 40

Counting Basics

Sum rule, product rule, bijection principle, and counting with constraints.

Fundamental Counting Principles

Product Rule (Multiplication Principle)

If a procedure has kk steps where:

  • Step 1 can be done in n1n_1 ways
  • Step 2 can be done in n2n_2 ways
  • ...
  • Step kk can be done in nkn_k ways

Then the total number of ways to do the procedure is: n1×n2××nkn_1 \times n_2 \times \cdots \times n_k

Example: How many 3-letter codes can be made from 26 letters? 26×26×26=263=17,57626 \times 26 \times 26 = 26^3 = 17,576

Sum Rule (Addition Principle)

If a task can be done in n1n_1 ways OR n2n_2 ways (mutually exclusive): n1+n2n_1 + n_2

Example: Choose a president from 10 men OR 8 women: 10+8=18 ways10 + 8 = 18 \text{ ways}

Subtraction Rule (Inclusion-Exclusion for 2 Sets)

If we count some items multiple times: AB=A+BAB|A \cup B| = |A| + |B| - |A \cap B|

Example: Bit strings of length 8 starting with 1 OR ending with 00:

  • Starting with 1: 27=1282^7 = 128
  • Ending with 00: 26=642^6 = 64
  • Both: 25=322^5 = 32
  • Answer: 128+6432=160128 + 64 - 32 = 160

Division Rule

If a procedure counts each outcome dd times: Actual count=Total countd\text{Actual count} = \frac{\text{Total count}}{d}

Example: Seating nn people around a circular table: n!n=(n1)!\frac{n!}{n} = (n-1)! (Rotations are considered the same)

Bijection Principle

If there's a bijection between sets AA and BB: A=B|A| = |B|

Counting one set by counting another equivalent set.

Example: Binary strings of length nn with kk ones == ways to choose kk positions from nn =(nk)= \binom{n}{k}

Counting with Constraints

"At least one" Problems

Often easier to use complement: At least one=TotalNone\text{At least one} = \text{Total} - \text{None}

Example: Bit strings of length 10 with at least one 1: 2101=10232^{10} - 1 = 1023 (Subtract the all-zeros string)

"At most" Problems

At most k=i=0k(exactly i)\text{At most } k = \sum_{i=0}^{k} \text{(exactly } i \text{)}

Or use complement: At most k=Total(more than k)\text{At most } k = \text{Total} - \text{(more than } k \text{)}

Common Counting Patterns

Bit Strings

DescriptionCount
Bit strings of length nn2n2^n
Bit strings of length nn with kk ones(nk)\binom{n}{k}
Bit strings of length nn starting with 12n12^{n-1}
Bit strings with even number of ones2n12^{n-1}

Strings from Alphabet

For alphabet of size rr:

DescriptionCount
Strings of length nnrnr^n
Strings of length nn with distinct charactersr(r1)(rn+1)r(r-1)\cdots(r-n+1)
Strings of length n\leq nrn+11r1\frac{r^{n+1}-1}{r-1}

Subsets

DescriptionCount
Subsets of nn-element set2n2^n
kk-element subsets(nk)\binom{n}{k}
Subsets of even size2n12^{n-1}
Subsets of odd size2n12^{n-1}

Tree Diagrams

Visualize sequential choices with a tree:

  • Each path from root to leaf is one outcome
  • Total outcomes = number of leaves

Complementary Counting

Count what you DON'T want and subtract: Want=TotalDon’t want|\text{Want}| = |\text{Total}| - |\text{Don't want}|

Example: Integers from 1 to 1000 NOT divisible by 5 or 7:

  • Total: 1000
  • Divisible by 5: 1000/5=200\lfloor 1000/5 \rfloor = 200
  • Divisible by 7: 1000/7=142\lfloor 1000/7 \rfloor = 142
  • Divisible by both (35): 1000/35=28\lfloor 1000/35 \rfloor = 28
  • Not divisible by 5 or 7: 1000(200+14228)=6861000 - (200 + 142 - 28) = 686

Double Counting

Count the same thing two different ways to establish an identity.

Example: Prove k=0n(nk)=2n\sum_{k=0}^{n} \binom{n}{k} = 2^n

Method 1: Sum counts all subsets of an nn-set. Method 2: Each element is in or out: 2n2^n subsets.

Therefore: k=0n(nk)=2n\sum_{k=0}^{n} \binom{n}{k} = 2^n

Counting Functions

| Type | Count (for f:ABf: A \to B, A=m|A|=m, B=n|B|=n) | |------|-------------------------------------------| | All functions | nmn^m | | Injections (one-to-one) | n!(nm)!=P(n,m)\frac{n!}{(n-m)!} = P(n, m) | | Surjections (onto) | Complex formula using inclusion-exclusion | | Bijections | n!n! (only when m=nm = n) |

Counting Proofs

Algebraic Proof

Use algebraic manipulation to prove identities.

Combinatorial Proof

Show both sides count the same thing.

Example: Prove (nk)=(nnk)\binom{n}{k} = \binom{n}{n-k}

Combinatorial proof:

  • Left: ways to choose kk elements to include
  • Right: ways to choose nkn-k elements to exclude
  • Both count the same subsets! \square