Discussion 6B

Counting

Sum Rule

If a choice is made in one of two ways, with aa options for the first and bb options for the second, then the number of ways to make the choice is a+ba+b.

Product Rule

The number of ways to make a sequence of two separate choices, with aa options for the first and bb options for the second, is aba \cdot b.

Combinatorics

Permutations

The number of ways to order nn objects is n!n!.
The number of ways to order kk objects from a set of nn objects is n!(nk)!\frac{n!}{(n-k)!}.

Combinations

The number of subsets of size kk for a set of size nn is n!k!(nk)!=(nk)\frac{n!}{k! (n-k)!} = \binom{n}{k}.
How many bitstrings of length nn have exactly kk ones?

Stars and Bars

You have room for nn fruits in your basket, and there are kk different types of fruit. How many ways can you fill up your basket with nn fruits?

You can partition your basket into kk groups so that placing a fruit in a group indicates that you take a fruit of that type. This partitioning can be accomplished using k1k-1 bars as the boundaries. Then the number of configurations is the number of ways to place the nn fruits and k1k-1 bars in a sequence, or (n+k1n)\binom{n+k-1}{n}.

Example: a basket with capacity n=5n=5 fruits and k=3k=3 types of fruits: apples, oranges, and bananas.
   apples          oranges          bananas
    ●  ●      |             |      ●  ●  ●

This is the same as the number of nonnegative integer solutions to napple+norange+nbanana=5n_{\text{apple}} + n_{\text{orange}} + n_{\text{banana}} = 5.

Summary

Selecting kk from nn:

With replacement
Without replacement
Ordered
nkn^k
n!(nk)!\frac{n!}{(n-k)!} permutations
Unordered
(n+k1n)\binom{n+k-1}{n}
(nk)\binom{n}{k} combinations

Inclusion-exclusion

AB=A+BAB| A \cup B | = |A| + |B| - |A \cap B|
Draw a Venn diagram.