Introduction to combinatorics (CSCI 2824, Spring 2015)

In this lecture we start the chapter on combinatoics, the art of counting discrete objects.

This page covers the following topics:

  • Four different types of discrete structures.

  • Basic counting rules

(Sections 5.1, 5.2 of the textbook)

Recap: Four different structure types in combinatorics

As we saw in the last lecture, when we talk about counting the number of combinations of elements from a set D, it is very important to identify the following two features:

  • are we allowed to draw the same element from D repeatedly?

  • does it matter which element from D is drawn first?

These two features defines four different basic discrete structures relevant to combinatorics:

  • ordered lists

  • unordered lists

  • permutations

  • combinations

Ordering matters Ordering does not matter
Repetitions allowed Ordered lists unordered lists
Repetitions not allowed Permutations Combinations

Case study: drawing two numbers from {1,2,ldots,n}

Today, we consider the following situation: suppose we have a set D={1,ldots,n} of n integers.

Category 1: Ordered lists

If we draw two integers from D in order and allowing repetition, how many possible outcomes are there?

This question concerns the number of distinct length-2 ordered lists whose entries are drawn from D. The possible outcomes that we are interested in can be described by the set

{(i,j), |, i,jin D} = Dtimes D.

So the answer is simply the cardinality of the set Dtimes D, i.e., |Dtimes D|=|D|*|D| = n^2.

Category 2: Unordered lists

If we draw two integers from D without order and allowing repetition, how many possible outcomes are there?

This question concerns the number of distinct length-2 unordered lists whose entries are drawn from D. The possible outcomes that we are interested in can be described by the set

{(i,j), |, i,jin D, ileq j}.

So the answer is given by the cardinality of this set, which is 1+2+cdots + n = frac{1}{2}n(n+1).

Category 3: Permutation

If we draw two integers from D in order but not allowing repetition, how many possible outcomes are there?

This question concerns the number of permutations of 2 objects from D. The possible outcomes that we are interested in can be described by the set

{(i,j), | , i,jin D, ineq j} = Dtimes D - {(i,i),| , iin D}.

So the answer is given by |Dtimes D|-|{(i,i),| , iin D}|=n^2-n.

Category 4: Sets

If we draw two inregers from D without order and bot allowing repetition, how many possible outcomes are there?

This question concerns the number of size-2 subsets of D. The possible outcomes that we are interested in can be described by the set

{(i,j), | , i,jin D, i<j},

which has 0+1+cdots+(n-1)=frac{1}{2}n(n-1) elements. Hence the answer is frac{1}{2}n(n-1).

Basic Rules for Counting

In this section, we mention some basic rules for counting, via set intersection/union. These rules look simple, but knowing how to apply them in practice can be really tricky!

The product rule

Product rule

If |A| = m and |B| = n then |A times B| = m * n.

More generally, given any sets A_1, A_2,ldots, A_k,

| A_1times A_2 times cdots times A_k | = |{(a_1, a_2, ldots, a_k) | a_1in A_1, a_2in A_2, ldots, a_kin A_k}| = |A_1|* |A_2|*cdots*|A_k|.

Example 1

We have 3 tee shirts with colors { red, green, blue } and 2 caps with labels {A,B}. How many possible ways are there of choosing a tee shirt and a cap?

Example 2

Let us say that in a tournament teams A, B and C play matches against each other in a round robin. How many matches are played?

How many possible outcomes are there for the tournament?

Solution To count matches is easy, we know that there are three matches to be played M1: A vs. B, M2: A vs. C and M3: B vs. C.

Each match has two outcomes. Winner1 = {A,B}, Winner2 = {A,C}, Winner3 = {B,C}. Therefore, applying the product rule are 2 2 2 = 8 outcomes overall.

The sum rule

Sum rule

If A and B are disjoint (i.e., Acap B=emptyset), then |A cup B| = |A| + |B|.

Example 3

We are allowed to make up a positive integer from the digits {1,3,5,7}. Each digit is to be used at most once (we may decide to skip a digit).

  • example of legal digits are: 13, 1, 3, 137, 7135, ….

Question: How many numbers can we make?

Solution: We split the problem into 4 disjoint counts: count all one digit numbers, two digit numbers, three digit and four digit numbers that can be formed. Together, using the rule of sums, we can simply add these counts and get the required overall count.

  • One digit numbers: 4 possible choices.

  • Two digit numbers: P(4,2) = 4times 3 =12 possible choices.

  • Thee digit numbers: P(4,3) = 4times 3times 2 = 24 possible choices.

  • Four digit numbers: P(4,4) = 4times 3times 2times 1 = 24 possible choices (remember 0! =1).

Adding them up we have 4 + 12 + 24 + 24 = 64 possible numbers.

Inclusion-exclusion principle

We have seen the formula for counting the elements in Acup B when A and B are disjoint. What if A and B are not disjoint, i.e., Acap B is not an empty set?

Inclusion-exclusion principle

For any sets A and B,

|Acup B| = |A|+|B| - |Acup B|.

Example 4

How many bit strings of length 10 either begin with three 1's or end with two 0's?

Rule of Complements

Rule of complements

Let A and U be two sets satisfying Asubseteq U, i.e., A is a subset of U. Then |A| = |U| - |U setminus A|. (Here Usetminus A denotes the set difference U minus A, i.e., Usetminus Atriangleq U-A triangleq {xin U,|, xnotin A}.)

Example 5

How many odd numbers are there between 45 and 101 (include both limits in your count).

Solution First let us just count the even numbers 46,48,... Why?

  1. 46 -> 1 even number

  2. 48 -> 2 even numbers

  3. 50 -> 3 even numbers

  4. n -> frac{(n-44)}{2} even numbers.

  5. 100 -> frac{56}{2} = 28 even numbers.

There are a total of 101-44= 57 numbers between 45 and 101.

Therefore, odd number count is 57 - 28 = 29.

Example 6

Let us say we toss a coin ten times. Each time we toss, we get a head or a tail.

  • How many possible outcomes are there for the ten tosses?

  • How many outcomes are there where we see two heads in succession or two tails in succession?