COMP2804: Discrete Structures II
$\newcommand{\R}{\mathbb{R}}\DeclareMathOperator{\E}{\mathbf{E}}\DeclareMathOperator{\deg}{deg}\newcommand{\N}{\mathbb{N}}$

Assignment 1

This assignment is a work-in-progress. A few new questions will be added after each lecture. The idea being that each new question applies or extends something covered in the lecture.

Lecture 1 (Sep 3 & 4)

When discussing graphs, $K_n$ denotes the graph with $n$ vertices $v_1,\ldots,v_n$ that contains all possible edges. That is, $K_n$ has vertex set $V(K_n)=\{v_1,\ldots,v_n\}$ and edge set $E(K_n)=\{v_iv_j: 1\le i< j\le n\}$. Here is what $K_3$, $K_4$, and $K_5$ look like when we draw them:

Complete graphs on 3, 4, and 5 vertices

The graph $K_3$ is also called a $3$-cycle and sometimes called a triangle.

Describe (or just draw) $K_1$ and $K_2$

Click to toggle answer

$K_1$ is the graph with only one vertex. $K_2$ is the graph with two vertices and $1$ edge.

For the rest of this question, when we use the word colouring we mean a colouring of the edges of a graph where each edge is coloured red or is coloured blue. When we use the term red $K_s$ we mean a colouring of $K_s$ where all edges are coloured red. When we use the term blue $K_t$ we mean a colouring of $K_t$ in which all edges are coloured blue.

For positive integers $s$ and $t$, let $R(s,t)$ denote the minimum integer $n$ such that any colouring of $K_n$ contains a red $K_s$ or a blue $K_t$.

In the first class, we showed that $R(3,3)\le 6$. Any colouring of $K_6$ contains a red $K_3$ (a red triangle) or it contains a blue $K_3$ (a blue triangle).

Prove that $R(3,3)>5$ by showing how to colour the edges of $K_5$ with the colours red and blue so that the resulting graph has no red triangle and no blue triangle.

Click to toggle answer

Complete graphs on 3, 4, and 5 vertices

Take a minute to convince yourself that, for any $s$ and $t$, $R(s,t)=R(t,s)$, since we can always swap the colours red and blue.

Question: What is the value of $R(3,2)$?
Hint: The proof that $R(3,3)\le 6$, from the first lecture contains the answer to this question.

Click to toggle answer

We will show that $R(3,2)=3$.

First we show that $R(3,2)\le 3$. Consider any colouring of $K_3$. If all edges are coloured red then we have a red $K_3$. Otherwise, at least one edge $v_iv_j$ of $K_3$ is coloured blue, in which case $v_iv_j$ is a blue $K_2$.

Next we show that $R(3,2)>2$. Colour the single edge of $K_2$ red. This colouring of $K_2$ does not contain any red triangle (since $K_2$ has only one edge and a triangle has three edges) and does not contain any blue edge, so it does not contain a red $K_3$ or a blue $K_2$.

Therefore $R(3,2)$ is an integer that is stricly greater than $2$ and less than or equal to $3$, so $R(3,2)=3$.

What is the value of $R(s,2)$ for each integer $s\ge 2$?

Click to toggle answer

We will show that, for any $s\ge 2$, $R(s,2)=s$.

First we show that $R(s,2)\le s$. Consider any colouring of $K_s$. If all edges are coloured red then we have a red $K_s$. Otherwise, at least one edge $v_iv_j$ of $K_s$ is coloured blue, in which case $v_iv_j$ is a blue $K_2$.

Next we show that $R(s,2)>s-1$. Colour all the edges of $K_{s-1}$ red. This colouring of $K_{s-1}$ does not contain any red $K_s$ (it only has $s-1$ vertices) and does not contain any blue edge, so it does not contain a red $K_s$ or a blue $K_2$.

Therefore $R(s,2)$ is an integer that is stricly greater than $s-1$ and less than or equal to $s$, so $R(s,2)=s$.

Prove that, for any integers $s, t\ge 3$, $R(s,t)\le R(s-1,t)+R(s,t-1)$.

Hint: The proof is very similar to the proof that $R(3,3)\le 6$ that, when looked at the right way, shows that $R(3,3)\le R(3,2)+R(2,3)$. The main difference is that, in that proof, we have an assumption, without loss of generality, that $r\ge b$. In the current setting, that assumption is no longer valid so you should split the argument into two cases instead.

Click to toggle answer

Let $n=R(s-1,t)+R(s,t-1)$ so we need to show that $R(s,t)\le n$. In other words, we need to show that any colouring of $K_n$ contains a red $K_s$ or a blue $K_t$.

Consider any colouring of $K_{n}$ and consider the vertex $v_1$ of $K_{n}$. There are $n-1$ edges of $K_{n}$ incident to $v_1$. Let $r$ be the number of these edges coloured red and let $b$ be the number of these edges coloured blue. Then $r+b=n-1$. It must be the case that $r\ge R(s-1,t)$ or $b\ge R(s,t-1)$ since, otherwise, $r\le R(s-1,t)-1$ and $b\le R(s,t-1)-1$, so $r+b \le n-2$. We consider each of these cases separately:

Lecture 2: Sep 8 & 9

Let $X$ be a set of size $n\ge 1$. How many ways are there to partition $X$ into three distinct sets $A$, $B$, and $C$ (so that $X=A\cup B\cup C$ and $A\cap B=B\cap C=A\cap C=\emptyset$)? Note that we allow any of the sets $A$, $B$, or $C$ to be empty.

Click to toggle answer

This is an easy application of the Product Rule. Let $x_1,\ldots,x_n$ be the elements of $X$. Define the following procedure: For each $i\in\{1,\ldots,n\}$, choose one of the sets $A$, $B$, or $C$ and add $x_i$ to this chosen set.

This is an $n$-step procedure and at each step $i$ we have $N_i=3$ options. Therefore, the number executions of the procedure is $N_1\times N_2\cdots N_n=3^n$. Clearly we can generate any partition of $X$ using this procedure and for any partition there is only one way to generate it using this procedure. Therefore, there are $3^n$ ways to partition $X$ into three sets $A$, $B$, and $C$.

There are lots of possible answers to this question. Another is to observe that this is the same as asking for the number of functions $f:X\to\{a,b,c\}$. That is, the number of ways of labelling the elements of $X$ with the set to which they should be assigned. In the first class we saw that the number of such functions is $3^n$.

Let $X$ be a set of size $n$. How many ways are there to define two disjoint subsets $A$ and $B$ of $X$ (so that $A\subseteq X$, $B\subseteq X$ and $A\cap B=\emptyset$)?

Click to toggle answer

This is very similar to the previous question. For each element $x\in X$, we get to choose if $x$ goes into $A$, or $x$ goes into $B$, or $x$ doesn't go into either set. Again, this gives an $n$ step procedure with $3$ choices at each step, so the answer is $3^n$.

Let $X$ be a set of size $n$. How many ways are there to define three sets $A$, $B$, and $C$ such that $A\subseteq X$, $B\subseteq X$, $C\subseteq X$ and $A\cup B\cup C=X$?

Click to toggle answer

Since $A\cup B\cup C=X$ any procedure we come up with has to make sure that $x$ belongs to at least one of $A$, $B$, or $C$ for each $x\in S$. This means that, for each $x\in S$ we have $7$ options for the sets that contain $x$, where each option corresponds to one of the $7$ non-empty subsets of $\{A,B,C\}$. More specifically, for each $x\in S$, we can have choose any of $\{C\}$, $\{B\}$, $\{B,C\}$, $\{A\}$, $\{A,C\}$, $\{A,B\}$ or $\{A,B,C\}$ and place $x$ into each of the sets we choose. This gives an $n$ step procedure for defining $A$, $B$, and $C$, where each step has $7$ options, so the answer is $7^n$.


Define a password as a sequence of 10 lowercase characters from the $26$-character lowercase alphabet $\{\mathtt{a},\mathtt{b},\ldots,\mathtt{z}\}$. How many possible passwords are there?

Click to toggle answer

This is another easy application of the Product Rule. The obvious procedure for generating such a password has $10$ steps and has $26$ options at each step, the answer is $26^{10}$. (Note that this is exactly like counting the number of functions $f:\{1,\ldots,10\}\to\{\mathtt{a},\mathtt{b},\ldots,\mathtt{z}\}$.)

In a bid to make passwords more secure and eliminate passwords like $\mathtt{aaaaaaaaaa}$, the creators of a password system insist that a password should a sequence of 10 distinct lowercase characters from the $26$-character lowercase alphabet $\{\mathtt{a},\mathtt{b},\ldots,\mathtt{z}\}$. How many possible passwords are there in this modified system?

Click to toggle answer

Again, this is easy to answer using the Product Rule with a $10$-step procedure. The only difference is that, when choosing the $i$th letter in the password, we are not allowed to choose any of the $i-1$ letters that appear before it. In our notation $N_i=26-(i-1)$. Then \[ N_1\times N_2\times\cdots\times N_{10}=26\times25\times\cdots\times 18\times 17=\frac{26!}{16!} \enspace . \] (Note that this is exactly like counting the number of one-to-one functions $f:\{1,\ldots,10\}\to\{\mathtt{a},\mathtt{b},\ldots,\mathtt{z}\}$.)

In a variation on this, someone suggests that, rather than require all characters in a password to be distinct, a password should not be allowed to contain two consecutive characters that are the same. For example, $\mathtt{abominably}$ is a valid password, but $\mathtt{unaccented}$ is not (because $\mathtt{c}$ appears twice consecutively). How many valid passwords are there in such a system?

Click to toggle answer

Again, we use the Product Rule with a $10$-step procedure. In the first step, we have $N_1=26$ options. In every subsequent step, we must choose a letter different from the one chosen in the previous step, we only have $N_i=25$ operations. So the the number of passwords $N_1\times N_2\times\cdots\times N_{10}=26\cdot 25^9$.

Lecture 3: Sep 8 & 9

Each of the following questions can be answered using the rules (Bijection, Complement, Sum, or Inclusion-Exclusion) introduced in Lecture 3.

$100$ COMP2804 students $c_1,\ldots,c_{100}$ and $100$ different PSYC1000 students $p_1,\ldots,p_{100}$ are writing an exam. (All students are distinct, even if they are writing the same exam.)

(Plenty of desks): Suppose the student are writing their exam in a room with $m\ge 200$ distinct desks $d_1,\ldots,d_m$. How many ways are there to assign the students to desks so that each student gets their own desk?

Click to toggle answer

The question is asking us to define a one-to-one function from the set $A$ of $n=200$ students onto the set $B=\{d_1,\ldots,d_m\}$ of $m$ desks. We have seen in class that the number of one-to-one functions from a set of size $n$ onto a set of size $m$ is $m!/(m-n)!$, so the answer is $m!/(m-200)!$.

(A shortage of desks, avoiding cheating): Suppose the exam room has exactly $100$ distinct standing desks $d_1,\ldots,d_{100}$ and no chairs. How many ways are there to assign students to desks so that each desk has exactly one COMP2804 student and exactly one PSYC1000 student?

Click to toggle answer

This can be solved with an application of the Product Rule using a $2$-step procedure. In the first step, we choose a one-to-one function that maps the COMP2804 students onto desks. There are $N_1=100!$ ways to do this. In the second step, we choose a one-to-one function that maps the PSYC1000 students onto desks. There are $N_2=100!$ ways to do this. Therefore, there are $N_1\times N_2=100!\times100!$ ways to do this.

(A shortage of desks, avoiding distractions) Like the previous question, suppose the exam room has exactly $100$ distinct standing desks $d_1,\ldots,d_{100}$ and no chairs. How many ways are there to assign the COMP2804 students to desks $d_1,\ldots,d_{50}$ and the PSYCH1000 students to desks $d_{51},\ldots,d_{100}$ so that each desk has exactly two students at it.

Click to toggle answer

This question is a bit trickier than the last, and is closely related to the number of rearrangements of a word (an example we cover in class). First we figure out how many ways there are to assign the COMP2804 students to the first $50$ desks, with $2$ students per desk. We do this with a $50$-step procedure. In the first step, we choose two of the $100$ students to assign to desk $d_1$. In the $i$th step we choose two of the $100-2(i-1)$ students that have not yet been assigned desks to place at desk $d_i$. Then, the number of ways to perform Step~$i$ is $\binom{100-2(i-1)}{2}$, so the total number of ways to assign the COMP2804 students to desks $d_1,\ldots,d_{50}$ with two students per desk is \[ \binom{100}{2}\binom{98}{2}\binom{96}{2}\cdots\binom{2}{2} = \frac{100\cdot99}{2!}\cdot\frac{98\cdot 97}{2!}\cdot\frac{96\cdot 95}{2!}\cdot\cdots\cdot \frac{2\cdot 1}{2!}=
\frac{100!}{2^{50}} \]

Next we have to assign the $100$ PSYC1000 students to the last fifty desks $d_{51},\ldots,d_{100}$. This is exactly the same as the number of ways of assigning the $100$ COMP2804 students to the first fifty desks, so this is also $100!/2^{50}$.

Thus, we have a $2$-step procedure with $N_1=100!/2^{50}$ ways to do the first step and $N_2=100!/2^{50}$ ways to do the second step, so the total number of ways to assign students to desks is $N_1\times N_2=(100!)^2/2^{100}$.

(Only three desks) Suppose the exam room has three really large tables, $t_1,t_2,t_3$, each of which can easily accommodate $200$ students. How many ways are there to assign students to these tables so that each table is assigned at least one student?. (The order in which students are assigned to table is unimportant.)

Click to toggle answer

For this, we will use the Complement Rule to first count solutions in which at least one of the tables is empty. The number of ways of assigning students so that they all sit at one table (leaving two tables empty) is $3$; you just choose the table. The number of ways of assigning students so that exactly one table is empty can be computed using the Product Rule. First choose one of the $3$ tables that will be empty. There are $3$ ways to do this. Next, assign the students to the other two tables so that neither of those is empty. The number of ways to do this is $2^n-2$ since, of the $2^n$ possible assignments of students to tables, the two assignments that have all students sitting at a single table are not allowed. Therefore, the number of assignments in which at least one table is empty is \[ 3 + 3\times (2^n-2) = 3\times 2^{n} - 3 \] Now we use the Complement Rule. The number of ways to assign students to tables without any restrictions is $3^n$. Therefore, the number of ways to assign students to tables in such a way that no table is empty is $3^n - (3\times 2^{n} - 3) = 3^n - 3\times 2^n + 3$.


Let $S_n$ be the set of all length-$n$ bitstrings, let $S^0_n\subseteq S_n$ be the set of length-$n$ bitstrings with an even number of $1$ bits and let $S^1_n=S_n\setminus S_n^0$ be the set of length-$n$ bitstrings with an odd number of $1$ bits.

For example, $S_3=\{000,001,010,011,100,101,110,111\}$, $S^0_3=\{000,011,101,110\}$ and $S^1_n=\{001,010,100,111\}$.

Prove, using the Bijection Rule, that for any $n\ge 1$, $|S^0_n|=|S^1_n|$ and then use the Sum Rule to show that $|S^0_n|=|S^1_n|=2^{n-1}$.

Click to toggle answer

Let $f:S_n\to S_n$ be the function that flips the first bit of its input string, so $f(\langle b_1,b_2,b_3,\ldots,b_n\rangle)=\langle (1-b_1),b_2,b_3,\ldots,b_n\rangle$. Notice that $f$ is the inverse of itself, so $f(f(\langle b_1,\ldots,b_n\rangle ))=\langle b_1,\ldots,b_n\rangle $. Note also that, if the number of $1$ bits in $\langle b_1,\ldots,b_n\rangle $ is even then the number of $1$-bits in $f(\langle b_1,\ldots,b_n\rangle )$ is odd. Therefore, we can also view $f$ as a function from $S^0_n$ to $S^1_n$ and the fact that $f$ is a self-inverse implies that this function is a bijection. There there exists a bijection $f:S^0_n\to S^1_n$ so, by the Bijection Rule $|S^0_n|=|S^1_n|$.

Notice that the sets $S^0_n$ and $S^1_n$ are disjoint and $S_n=S^0_n\cup S^1_n$ so, by the Sum Rule \[ |S_n|=|S^0_n\cup S^1_n|=|S^0_n|+|S^1_n|=2|S^0_n| \enspace . \] Dividing the left and right hand sides by $2$ gives $|S^0_n|=\tfrac{1}{2}|S_n|=\tfrac{1}{2}\cdot 2^n = 2^{n-1}$.

Let $T_n$ be the set of length-$n$ tritstrings (length-$n$ strings over the alphabet $\{0,1,2\}$). For each $i\in\{0,1,2\}$ let $T^i_n=\{\langle t_1,\ldots,t_n\rangle\in T_n:\sum_{j=1}^n t_j\equiv i\pmod 3\}$.

Prove, using the Bijection Rule or something like it, that $|T^i_n|=\tfrac{1}{3}T_n$, for each $i\in\{0,1,2\}$.

Click to toggle answer

This is similar to the previous question: Let $f:T_n\to T_n$ be the function that adds $1$ (mod $3$) to the first trit in its input. More precisely, \[
f(\langle t_1,t_2,t_3,\ldots,t_n\rangle)=\langle (t_1+1)\bmod 3,t_2,t_3,\ldots,t_n\rangle \enspace . \] Then $f$ is a bijection from $T_n^0$ to $T_n^1$, so $|T_n^0|=|T_n^1|$. Also, $f$ is a bijection from $T_n^1$ onto $T_n^2$, so $|T_n^1|=|T_n^2|$. Therefore $|T_n^0|=|T_n^1|=|T_n^2|$. By the Sum Rule, $|T_n^0|+|T_n^1|+|T_n^2|=|T_n|$. Combining these equations shows that $3|T^i_n|=T_n$, for each $i\in\{0,1,2\}$ and dividing both sides of this equation by $3$ answers the question.

Lecture 4: Sep 15 & 16

In how many ways can you paint 200 distinct chairs, if $75$ of them must be painted red, $25$ of them must be painted green, and $100$ of them must be painted blue?

Click to toggle answer

This an application of the Product Rule using binomial coefficients. Here's the procedure:

  1. Choose $75$ of the chairs and paint them red. There are $\binom{200}{75}$ ways to do this.
  2. Choose $25$ of the remaining $125$ unpainted chairs and colour them green. There are $\binom{125}{25}$ ways to do this.
  3. Paint the remaining $100$ chairs blue. There only one way to do this.

So, by the Product Rule, there are $\binom{200}{75}\cdot\binom{125}{25}$ ways to paint the chairs so that we have $75$ red, $25$ green, and $100$ blue chairs.

If you use the Produce Rule in other ways, you may get different-looking answers like $\binom{200}{100}\cdot\binom{100}{25}$ or $\binom{200}{25}\cdot\binom{175}{100}$.

A tic-tac-toe board is a $3\times 3$ grid in which each cell is either empty, contains an X or contains an O. A cell with an X or an O is called a marked cell. If the number of marked cells in a board is $m$, then $\lceil m/2\rceil$ of the marked cells must contain an X and $\lfloor m/2\rfloor$ of the marked cells must contain an O.

How many tic-tac-toe boards are there with $9$ marked cells?

Click to toggle answer

In a board with $9$ marked cells, all cells are marked. Such a board is completely defined by the choice of the $\lceil 9/2\rceil=5$ cells that contain X. Therefore there $\binom{9}{5}$ tic-tac-toe boards with $9$ marked cells.

How many tic-tac-toe boards are there with $5$ marked cells?

Click to toggle answer

In a board with $5$ marked cells, $\lceil 5/2\rceil=3$ of the marked cells contain X and the remaining $2$ marked cells contain O. We can define such a board with a $2$-step procedure:

  1. Choose $3$ cells that will contain X. There are $\binom{9}{3}$ ways to do this.

  2. From the remaining $6$ unmarked cells, choose $2$ cells that will contain O. There are $\binom{6}{2}$ ways to do this.

Therefore, the number of number of tic-tac-toe boards with $5$ marked cells is $\binom{9}{3}\cdot\binom{6}{2}$.

Note that this is more than the number of tic-tac-toe boards with $9$ marked cells. Isn't that interesting?

Let $S=\{1,\ldots,21\}$. An ordered partition of $S$ into $3$-element sets is a sequence of seven $3$-element sets $P_1,\ldots,P_7$ such that $\bigcup_{i=1}^7 P_i = S$. For example, \[ \langle\{1,3,5\},\{2,4,6\},\{7,8,9\},\{10,11,12\},\{13,14,15\}, \{16,17,18,\},\{19,20,21\} \rangle \] and \[ \langle\{1,3,5\},\{7,8,9\},\{2,4,6\},\{10,11,12\},\{13,14,15\}, \{16,17,18,\},\{19,20,21\} \rangle \] are two different ordered partitions of $S$. Prove that the number of ordered partitions of $S$ is \[ \frac{21!}{6^7} \enspace . \]

Click to toggle answer

We can construct an ordered partition using a $7$-step procedure, where step $i$ involves choosing the $3$ elements in $P_i$ from the $(21-3(i-1))$-element set $S\setminus(P_1\cup\cdots\cup P_{i-1})$, for each $i\in\{1,ldots,7\}$. Then the number of ways to perform step $i$ is $N_i\binom{21-3(i-1)}{3}$. Therefore, the number of ordered partitions is \begin{align*} \prod_{i=1}^7 \binom{21-3(i-1)}{3} & = \binom{21}{3} \binom{18}{3} \binom{15}{3} \binom{12}{3} \binom{9}{3} \binom{6}{3} \binom{3}{3} \\ & = \frac{21\cdot 20\cdot 19}{3!} \frac{18\cdot 17\cdot 16}{3!} \frac{15\cdot 14\cdot 13}{3!} \frac{12\cdot 11\cdot 10}{3!} \frac{9\cdot 8\cdot 7}{3!} \frac{6\cdot 5\cdot 4}{3!} \frac{3\cdot 2\cdot 1}{3} \\ & = \frac{21!}{(3!)^7} = \frac{21!}{6^7} \enspace . \end{align*}

Continuing from the previous question, an unordered partition of $S$ into $3$-element sets is a $7$-element set $\mathcal{P}$ with $\bigcup_{P\in\mathcal{P}} P=S$, and $|P|=3$ for each $P\in\mathcal{P}$. For example, \[ \{\{1,3,5\},\{2,4,6\},\{7,8,9\},\{10,11,12\},\{13,14,15\}, \{16,17,18,\},\{19,20,21\} \} \] and \[ \{\{1,3,5\},\{7,8,9\},\{2,4,6\},\{10,11,12\},\{13,14,15\}, \{16,17,18,\},\{19,20,21\} \} \] are two ways of writing the same unordered partition.

Use a "Combinatorial Proof" to show that the number of unordered partitions of $S$ is \[ \frac{21!}{6^7\cdot 7!} \enspace . \]

Click to toggle answer

Define $q$ to be the number of unordered partitions. Let us count the number of ordered partitions using the Product Rule with $2$-step procedure.
1. Choose an unordered partition $\mathcal{P}$. By definition, there are $N_1=q$ ways to do this. Then $\mathcal{P}$ is a $7$-element set.
2. Choose a permutation $P_1,\ldots,P_7$ of $\mathcal{P}$, which gives us an ordered partition. There are $N_2=7!$ ways to do this.

Therefore, the number of ordered partitions is $N_1\cdot N_2=q\cdot 7!$. But in the previous question, we showed that the number of ordered partitions is $\frac{21!}{6^7}$. Therefore, $q\cdot 7! = \frac{21!}{6^7}$ and dividing both sides by $7!$ gives $q=\frac{21!}{6^7\cdot 7!}$, which is what we are trying to prove.

Let's try to prove Newton's Binomial Formula $(x+y)^n=\sum_{k=0}^n \binom{n}{k}x^{n-k}y^k$ with a proof by induction on $n$. Technical condition: We should assume that $x+y\neq 0$ or we should define $0^0=1$.

For a proof by induction, we need to establish the base case, which we will take to be $n=0$. Then $(x+y)^0=1$ and $\sum_{k=0}^0 \binom{0}{k}x^{0-k}y^{k}=\binom{0}{0}x^{0-0}y^0=1$, so the left and hand side and right hand side of the formula are both equal to $1$.

Next, assume that $n\ge 1$ and that the formula holds for $n-1$. That is, we assume that $(x+y)^{n-1}=\sum_{k=0}^{n-1}\binom{n-1}{k}x^{n-1-k}y^k$. Then \begin{align*} (x+y)^n & = (x+y)(x+y)^{n-1} \\ & = (x+y)\sum_{k=0}^{n-1}\binom{n-1}{k}x^{n-1-k}y^k \\ & = \sum_{k=0}^{n-1}\binom{n-1}{k}x^{n-k}y^k + \sum_{k=0}^{n-1}\binom{n-1}{k}x^{n-1-k}y^{k+1} \\ \end{align*} Now, you finish the proof.
Hint: Try writing the last equation longhand for some small value of $n$, like $3$ or $4$ and notice that for most values of $k$, the factor $x^{n-k}y^k$ appears in exactly two terms.

Click to toggle answer

The hint (and Pascal's Triangle/Identity) suggests that most of the coefficients $\binom{n}{k}$ that we are looking for will appear disguised as $\binom{n-1}{k}+\binom{n-1}{k-1}$. In particular, we'll try to find $\binom{n}{1},\binom{n}{2},\ldots,\binom{n}{n-1}$ this way. We'll find $\binom{n}{0}$ and $\binom{n}{n}$ separately. Continuing from the last equation above, \begin{align*} & = \color{red}{\sum_{k=0}^{n-1}\binom{n-1}{k}x^{n-k}y^k} + \color{blue}{\sum_{k=0}^{n-1}\binom{n-1}{k}x^{n-1-k}y^{k+1}} \\ & = \color{red}{\sum_{k=0}^{n-1}\binom{n-1}{k}x^{n-k}y^k} + \color{blue}{\sum_{k=1}^{n}\binom{n-1}{k-1}x^{n-k}y^{k}} \\ & = \color{red}{\binom{n-1}{0}x^n+\sum_{k=1}^{n-1}\binom{n-1}{k}x^{n-k}y^k} + \color{blue}{\sum_{k=1}^{n}\binom{n-1}{k-1}x^{n-k}y^{k}} & \text{(we found $\binom{n}{0}=\binom{n-1}{0}=1$)} \\ & = \color{red}{\binom{n-1}{0}x^n+\sum_{k=1}^{n-1}\binom{n-1}{k}x^{n-k}y^k} + \color{blue}{\sum_{k=1}^{n-1}\binom{n-1}{k-1}x^{n-k}y^{k} + \binom{n-1}{n-1}y^{n}} & \text{(we found $\binom{n}{n}=\binom{n-1}{n-1}=1$)}\\ & = \color{red}{\binom{n}{0}x^n+\sum_{k=1}^{n-1}\binom{n-1}{k}x^{n-k}y^k} + \color{blue}{\sum_{k=1}^{n-1}\binom{n-1}{k-1}x^{n-k}y^{k} + \binom{n}{n}y^{n}} \\ & = \color{red}{\binom{n}{0}x^n}+\sum_{k=1}^{n-1}\left(\color{red}{\binom{n-1}{k}} + \color{blue}{\binom{n-1}{k-1}}\right)\color{purple}{x^{n-k}y^{k}} + \color{blue}{\binom{n}{n}y^{n}} & \text{(combine both sums)}\\ & = \color{red}{\binom{n}{0}x^n}+\color{purple}{\sum_{k=1}^{n-1}\binom{n}{k}x^{n-k}y^{k}} + \color{blue}{\binom{n}{n}y^{n}} & \text{(Pascal's Identity: $\color{purple}{\binom{n}{k}}=\color{red}{\binom{n-1}{k}}+\color{blue}{\binom{n-1}{k-1}}$)} \\ & = \color{purple}{\sum_{k=0}^{n}\binom{n}{k}x^{n-k}y^{k}} \enspace . \end{align*}

Lecture 5: Sep 17 & 18

What is the number of rearrangements of the $22$-letter word ``ELECTROENCEPHALOGRAPHS'' are there?

Click to toggle answer

The letter frequencies in this word are $4\times\mathrm{E}$, $2\times\mathrm{L}$, $2\times\mathrm{C}$, $1\times\mathrm{T}$, $2\times\mathrm{R}$, $2\times\mathrm{O}$, $1\times\mathrm{N}$, $2\times\mathrm{P}$, $2\times\mathrm{H}$, $2\times\mathrm{A}$, $1\times\mathrm{G}$, $1\times\mathrm{S}$.
We can create a rearrangement by a procedure that starts with $22$ blank spaces, chooses $4$ of them for the letter $E$, then chooses $2$ of the remaining $18$ for the letter L, and so on. Proceeding this way, we get the answer: \[ \binom{22}{4} \binom{18}{2} \binom{16}{2} \binom{14}{1} \binom{13}{2} \binom{11}{2} \binom{9}{1} \binom{8}{2} \binom{6}{2} \binom{4}{2} \binom{2}{1} \binom{1}{1} \enspace . \] If you were paying attention in class, I mentioned that there is something called the multinomial formula that lets you read off the answer directly from the length of the word and the letter frequencies. Using this we get the (equivalent) answer: \[ \frac{22!}{(4!)(2!)^7} \enspace . \]

How many non-negative integer solutions are there to the equation $x_1+x_2+x_3+x_4+x_5=112$?

Click to toggle answer

We saw a Theorem in class that answers this (Theorem 3.9.2) in the textbook. Applying this theorem with $n=112$ and $k=5$, we get the answer \[ \binom{n+k-1}{k-1}=\binom{112+5-1}{5-1}=\binom{116}{4} \enspace . \]

How many non-negative integer solutions are there to the equation $x_1+x_2+x_3+x_4+x_5=112$ with the additional condition that $x_1\ge 10$?

Click to toggle answer

The condition $x_1\ge 10$ requires that we do some rewriting. Let $y_1=x_1-10$ and consider the equation $y_1+x_2+x_3+x_4+x_5=102$. For any non-negative integer solution to this equation, we can set $x_1\gets y_1+10$ to obtain a solution to the original equation in which $x_1\ge 10$. In the other direction, for any non-negative integer solution $x_1,x_2,\ldots,x_5$ to the original equation with $x_1\ge 10$, we can set $y_1\gets x_1-10$ to get a non-negative integer solution to $y_1+x_2+x_3+x_4+x_5=102$. Therefore, there is a bijection between non-negative integer solutions to $y_1+x_2+x_3+x_4+x_5=102$ and non-negative integer solutions to $x_1+x_2+x_3+x_4+x_5=112$ with the extra condition $x_1\ge 10$. Now, applying Theorem 3.9.1 with $n=102$ and $k=5$ we get the answer \[ \binom{n+k-1}{k-1}=\binom{102+5-1}{5-1}=\binom{106}{4} \enspace . \]

How many non-negative integer solutions are there to the inequality $x_1+x_2+x_3+x_4+x_5\le 112$?

Click to toggle answer

In class, we saw a theorem (Theorem 3.9.2 in the textbook) that considers exactly this problem. Applying Theorem 3.9.2 with $n=112$ and $k=5$ gives the answer \[ \binom{n+k}{k}=\binom{112+5}{5}=\binom{117}{5} \enspace . \]

Prove the following binomial identity by counting something two different ways: \[ \binom{n+k}{k} = \sum_{r=0}^n \binom{r+k-1}{k-1} \]

Click to toggle answer

The thing we will count is the number of non-negative integer solutions to the inequality \[ x_1+x_2+\cdots+x_k \le n \] Let $S$ be the set of all solutions to this inequality. By Theorem 3.9.2, \[ |S| = \binom{n+k}{k} \] We can also compute $|S|$ using the Sum Rule. For each $r\in\{0,\ldots,n\}$, let $S_r$ be the set of all non-negative integer solutions to $x_1+x_2+\cdots+x_k=r$. Then, by Theorem 3.9.1, $|S_r|=\binom{r+k-1}{k-1}$. Notice that the sets $S_0,\ldots,S_n$ are pairwise disjoint and $S=\bigcup_{r=0}^n S_r$. Therefore, by the Sum Rule, \[ |S| = \sum_{r=0}^n |S_r| = \sum_{r=0}^n \binom{r+k-1}{k-1} \enspace. \] Putting these two solutions together we get the identity \[ \binom{n+k}{k} = |S| = \sum_{r=0}^n \binom{r+k-1}{k-1} \]

End of Assignment 1