Answers to exercises
2 Let us count!
2.1 A party
2.1. .
2.1. Carl: . Diane: .
2.2 Sets
2.2. (a) all houses in a street; (b) an Olympic team; (c) class of ’99; (d) all trees in a forest; (e) the set of rational numbers; (f) a circle in the plane.
2.2. (a) soldiers; (b) people; (c) books; (d) animals.
2.2. (a) all cards in a deck; (b) all spades in a deck; (c) a deck of Swiss cards; (d) non-negative integers with at most two digits; (e) non-negative integers with exactly two digits; (f) inhabitants of Budapest, Hungary.
2.2. Alice, and the set whose only element is the number .
2.2. .
2.2. No.
2.2. , , , , , , , . subsets.
2.2. women; people at the party; students of Yale.
2.2. or . The smallest is .
2.2. (a) . (b) The union operation is associative. (c) The union of any set of sets consists of those elements which are elements of at least one of the sets.
2.2. The union of a set of sets is the smallest set containing each as a subset.
2.2. .
2.2. The cardinality of the union is at least the larger of and and at most .
2.2. (a) ; (b) ; (c) .
2.2. The cardinality of the intersection is at most the minimum of and .
2.2. The common elements of and are counted twice on both sides; the elements in either or but not both are counted once on both sides.
2.2. (a) The set of negative even integers and positive odd integers. (b) .
2.3 The number of subsets
2.3. Powers of .
2.3. .
2.3. (a) ; (b) .
2.3. .
2.4 Sequences
2.4. The trees have and leaves, respectively.
2.4. .
2.4. .
2.4. .
2.4. .
2.4. .
2.5 Permutations
2.5. .
2.5. (b) . In general, .
2.5. (a) is larger for . (b) is larger for .
2.5. (a) This is true for . (b) for .
3 Induction
3.1 The sum of odd numbers
3.1. One of and is even, so the product is even. By induction: true for ; if then
and is even by the induction hypothesis, is even, and the sum of two even numbers is even.
3.1. True for . If then
3.1. The youngest person will count handshakes. The -th oldest will count handshakes. So they count
handshakes. We also know that there are handshakes.
3.1. Compute the area of the rectangle in two different ways.
3.1. By induction on , true for . For , we have
3.1. If is even, then
so the sum is
If is odd then we have to add the middle term separately.
3.1. If is even, then
so the sum is
Again, if is odd the solution is similar, but we have to add the middle term separately.
3.1. By induction. True for . If then
3.1. By induction. True for . If then
3.2 Subset counting revisited
3.2. (Strings) True for . If then to get a string of length we can start with a string of length (this can be chosen in ways by the induction hypothesis) and append an element (this can be chosen in ways). So we get .
(Permutations) True for . To seat people, we can start with seating the oldest (this can be done in ways) and then seating the rest (this can be done in ways by the induction hypothesis). We get .
3.2. True if . Let . The number of handshakes between people is the number of handshakes by the oldest person () plus the number of handshakes between the remaining (which is by the induction hypothesis). We get
13.1. By induction. True if . Let . Assume the description of the coloring is valid for the first circles. If we add the -th, the color and the parity do not change outside this circle; both change inside the circle. So the description remains valid.
13.1. (a) By induction. True for line. Adding a line, we recolor all regions on one side. (b) One possible description: designate a direction as “up”. Let be any point not on any of the lines. Start a semiline “up” from . Count how many of the given lines intersect it. Color according to the parity of this intersection number.
3.2. We did not check the base case .
3.2. The proof uses that there are at least four lines. But we only checked as base cases. The assertion is false for and also for every value after that.
3.3 Counting regions
3.3. True for . Let . Delete any line. The remaining lines divide the plane into
regions by the induction hypothesis. The last line cuts of these into two. So we get
4 Counting subsets
4.1 The number of ordered subsets
4.1. (I don’t think you could really draw the whole tree; it has almost leaves. It has levels of nodes.)
4.1. (a) . (b) . (c) .
4.1. .
4.1. In one case, repetition is not allowed, while in the other case, it is allowed.
4.2 The number of subsets of a given size
4.2. Handshakes; lottery; hands in bridge.
4.2. See next chapter.
4.2. .
4.2. Solution of (b) ((a) is a special case). The identity is
The right-hand side counts -subsets of an -element set by separately counting those that do not contain a given element and those that do.
4.2. The number of -element subsets is the same as the number of -element subsets, since the complement of a -subset is an -subset and vice versa.
4.2. Both sides count all subsets of an -element set.
4.2. Both sides count the number of ways to divide an -element set into three sets with , , and elements.
4.3 The Binomial Theorem
4.3.
4.3. (a) . (b) By .
4.3. Both sides count all subsets of an -element set.
4.4 Distributing presents
4.4.
since .
4.4. (a) (distribute positions instead of presents).
(b) (distribute as “presents” the first positions at the competition and participation certificates).
(c) .
(d) Chess seating in Diane’s sense (distribute players to boards).
4.4. (a) .
(b) .
(c) .
4.5 Anagrams
4.5. .
4.5. COMBINATORICS.
4.5. Most: any word with different letters; least: any word with identical letters.
4.5. (a) .
(b) ways to select the four letters that occur; for each selection, ways to select the two letters that occur twice; for each selection, we distribute positions to these letters ( of them get positions), this gives ways. Thus we get
(There are many other ways to arrive at the same number!)
(c) Number of ways to partition into the sum of positive integers:
which makes possibilities.
(d) This is too difficult in this form. What was meant is the following: how many words of length are there such that none is an anagram of another? This means distributing pennies to children, and so the answer is
4.6 Distributing money
4.6. .
4.6. .
4.6. .
5 Pascal’s Triangle
5. Basic identities
- This is the same as
\binom{n}{0} = \binom{n}{n} = 1
\begin{aligned} 1 + \binom{n}{1} + \binom{n}{2} + \dots + \binom{n}{n-1} + \binom{n}{n} &= 1 + \Bigl(\binom{n-1}{0} + \binom{n-1}{1}\Bigr) + \Bigl(\binom{n-1}{1} + \binom{n-1}{2}\Bigr) \ &\quad + \dots + \Bigl(\binom{n-1}{n-2} + \binom{n-1}{n-1}\Bigr) + 1 \ &= 2\Bigl(\binom{n-1}{0} + \binom{n-1}{1} + \dots + \binom{n-1}{n-2} + \binom{n-1}{n-1}\Bigr) \ &= 2 \cdot 2^{n-1} = 2^n. \end{aligned}
5.1. The coefficient of $x^n y^n$ in\Bigl( \binom{n}{0} x^n + \binom{n}{1}(x^{n-1}y + x^{n-2}y^2) + \dots + \binom{n}{n-1} x y^{n-1} + \binom{n}{n} y^n \Bigr)
\binom{n}{0}\binom{n}{n}
- \binom{n}{1}\binom{n}{n-1}
- \dots + \binom{n}{n-1}\binom{n}{1}
- \binom{n}{n}\binom{n}{0}.
k = \left\lfloor \frac{n - \sqrt{2n}}{2} \right\rfloor.
\Bigl(\binom{n}{k+1} - \binom{n}{k}\Bigr)
\Bigl(\binom{n}{k} - \binom{n}{k-1}\Bigr),
and determines the value of $k$ where it turns negative.) 5.2. (a) $2^n$ is a sum with positive terms in which $\binom{n}{4}$ is only one of the terms. (b) Assume that $n > 200$. Then\frac{2^n}{n^3} ;\ge; \frac{\binom{n}{4}}{n^3}
\frac{n(n-1)(n-2)(n-3)}{24n^3}
\frac{(n/2)^3}{24n^3} = \frac{n}{192} > 1.
\binom{n}{n/2} = \frac{n!}{\bigl((n/2)!\bigr)^2} \sim \frac{\left(\dfrac{n}{e}\right)^n \sqrt{2\pi n}}{ \left(\dfrac{n}{2e}\right)^n \bigl(\sqrt{\pi n}\bigr)^2} = \frac{\left(\dfrac{n}{e}\right)^n \sqrt{2\pi n}}{ \left(\dfrac{n}{2e}\right)^n \pi n} = 2^n \frac{\sqrt{2}}{\sqrt{\pi n}}.
\frac{\binom{2m}{m}}{\binom{2m}{m - t}} > \frac{t^2}{m},
it is enough to find a $t > 0$ for which $t^2/m \ge 1/c$. Solving for $t$, we get thatt = \left\lceil \sqrt{\frac{m}{c}} \right\rceil
is a good choice. 5. (a) See (c). (b) We prove by induction on $s$ that for $0 \le s \le m - t$,\frac{\binom{2m}{m - s}}{\binom{2m}{m - t - s}} > \frac{t^2}{m}.
For $s = 0$ this is just the theorem we already know. Let $s > 0$. Then\binom{2m}{m - s} = \frac{m - s + 1}{m + s}\binom{2m}{m - s + 1},
\binom{2m}{m - t - s} = \frac{m - s - t + 1}{m + s + t}\binom{2m}{m - t - s + 1}.
\begin{aligned} \frac{\binom{2m}{m - s}}{\binom{2m}{m - t - s}} &= \frac{m - s + 1}{m + s} \cdot \frac{m + s + t}{m - s - t + 1} \cdot \frac{\binom{2m}{m - s + 1}}{\binom{2m}{m - t - s + 1}} \ &= \frac{(m - s + 1)(m + s + t)}{(m + s)(m - s - t + 1)} \cdot \frac{\binom{2m}{m - s + 1}}{\binom{2m}{m - t - s + 1}}. \end{aligned}
\frac{(m - s + 1)(m + s + t)}{(m + s)(m - s - t + 1)} > 1,
\frac{\binom{2m}{m - s}}{\binom{2m}{m - t - s}}
\frac{\binom{2m}{m - s + 1}}{\binom{2m}{m - t - s + 1}}
\frac{t^2}{m}
\begin{aligned} \frac{\binom{2m}{m - s}}{\binom{2m}{m - t - s}} &= \frac{(2m)!}{(m - s)!(m + s)!} \cdot \frac{(m - t - s)!(m + t + s)!}{(2m)!} \ &= \frac{(m + t + s)(m + t + s - 1)\cdots(m + s + 1)}{ (m - s)(m - s - 1)\cdots(m - s - t + 1)} \ &= \frac{m + t + s}{m - s} \cdot \frac{m + t + s - 1}{m - s - 1} \cdots \frac{m + s + 1}{m - s - t + 1} \ &= \left(1 + \frac{t + 2s}{m - s}\right) \left(1 + \frac{t + 2s}{m - s - 1}\right) \cdots \left(1 + \frac{t}{m - s - t + 1}\right) \ &\ge \left(1 + \frac{t + 2s}{m}\right)
1 + t,\frac{t + 2s}{m}. \end{aligned}
--- # 6 Fibonacci numbers --- **6.1 Fibonacci’s exercise** 6.1. Because we use the two previous elements to compute the next. 6.1. $F_{n+1}$. --- **6.2** 6.2. It is clear from the recurrence that two odd members are followed by an even, then by two odd. 6.2. We formulate the following statement: if $n$ is divisible by $5$, then so is $F_n$; if $n$ has remainder $1$ when divided by $5$, then $F_n$ has remainder $1$; if $n$ has remainder $2$ when divided by $5$, then $F_n$ has remainder $1$; if $n$ has remainder $3$ when divided by $5$, then $F_n$ has remainder $2$; if $n$ has remainder $4$ when divided by $5$, then $F_n$ has remainder $3$. This is then easily proved by induction on $n$. 6.2. By induction. All of them are true for $n = 1$ and $n = 2$. Assume that $n \ge 3$. (a)\begin{aligned} F_1 + F_3 + F_5 + \dots + F_{2n-1} &= (F_1 + F_3 + \dots + F_{2n-3}) + F_{2n-1} \ &= F_{2n-2} + F_{2n-1} \ &= F_{2n}. \end{aligned}
\begin{aligned} F_0 - F_1 + F_2 - F_3 + \dots - F_{2n-1} + F_{2n} &= (F_0 - F_1 + F_2 - \dots + F_{2n-2}) - (F_{2n-1} + F_{2n}) \ &= (F_{2n-3} - 1) + F_{2n-2} \ &= F_{2n-1} - 1. \end{aligned}
\begin{aligned} F_0^2 + F_1^2 + F_2^2 + \dots + F_n^2 &= (F_0^2 + F_1^2 + \dots + F_{n-1}^2) + F_n^2 \ &= F_{n-1}F_n + F_n^2 \ &= F_n(F_{n-1} + F_n) \ &= F_n F_{n+1}. \end{aligned}
\begin{aligned} F_{n-1}F_{n+1} - F_n^2 &= F_{n-1}(F_{n-1} + F_n) - F_n^2 \ &= F_{n-1}^2 + F_n(F_{n-1} - F_n) \ &= F_{n-1}^2 - F_n F_{n-2} \ &= -(-1)^{n-1} \ &= (-1)^n. \end{aligned}
\binom{n}{0}
- \binom{n-1}{1}
- \binom{n-2}{2}
- \dots
- \binom{n-k}{k} = F_{n+1},
\begin{aligned} \binom{n}{0}
- \binom{n-1}{1}
- \binom{n-2}{2}
- \dots
- \binom{n-k}{k} &= 1 + \Bigl(\binom{n-2}{0} + \binom{n-2}{1}\Bigr) + \Bigl(\binom{n-3}{1} + \binom{n-3}{2}\Bigr)
- \dots \ &\quad + \Bigl(\binom{n-k-1}{k-1} + \binom{n-k-1}{k}\Bigr) \ &= \Bigl(\binom{n-1}{0}
- \binom{n-2}{1}
- \binom{n-3}{2}
- \dots
- \binom{n-k-1}{k}\Bigr) \ &\quad + \Bigl(\binom{n-2}{0}
- \binom{n-3}{1}
- \dots
- \binom{n-k-1}{k-1}\Bigr) \ &= F_n + F_{n-1} \ &= F_{n+1}. \end{aligned}
F_{n+1}F_{n-1} - F_n^2 = (-1)
is very small compared to $F_n^2$. --- **6.3 A formula for the Fibonacci numbers** 6.3. True for $n = 0, 1$. Let $n \ge 2$. Then by the induction hypothesis,\begin{aligned} F_n &= F_{n-1} + F_{n-2} \ &= \frac{1}{\sqrt{5}}\left[\left(\frac{1 + \sqrt{5}}{2}\right)^{n-1}
- \left(\frac{1 - \sqrt{5}}{2}\right)^{n-1}\right]
- \frac{1}{\sqrt{5}}\left[\left(\frac{1 + \sqrt{5}}{2}\right)^{n-2}
- \left(\frac{1 - \sqrt{5}}{2}\right)^{n-2}\right] \ &= \frac{1}{\sqrt{5}}\left[ \left(\frac{1 + \sqrt{5}}{2}\right)^{n-2} \left(\frac{1 + \sqrt{5}}{2} + 1\right)
\left(\frac{1 - \sqrt{5}}{2}\right)^{n-2} \left(\frac{1 - \sqrt{5}}{2} + 1\right) \right] \ &= \frac{1}{\sqrt{5}}\left[ \left(\frac{1 + \sqrt{5}}{2}\right)^n
\left(\frac{1 - \sqrt{5}}{2}\right)^n \right]. \end{aligned}
6.3. For $n = 0$ and $n = 1$, if we require that $H_n$ is of the given form we getH_0 = 1 = a + b, \qquad H_1 = 3 = a \frac{1 + \sqrt{5}}{2} + b \frac{1 - \sqrt{5}}{2}.
Solving for $a$ and $b$, we geta = \frac{1 + \sqrt{5}}{2}, \qquad b = \frac{1 - \sqrt{5}}{2}.
H_n = \left(\frac{1 + \sqrt{5}}{2}\right)^{n+1} + \left(\frac{1 - \sqrt{5}}{2}\right)^{n+1}
follows by induction on $n$ just like in the previous problem. 6.3.I_n = \frac{1}{2\sqrt{5}} \bigl((2 + \sqrt{5})^n - (2 - \sqrt{5})^n\bigr).
--- # 7 Combinatorial probability --- **7.1 Events and probabilities** 7.1. The union of two events $A$ and $B$ corresponds to “$A$ or $B$”. 7.1. It is the sum of some of the probabilities of outcomes, and even if we add all we get just $1$. 7.1. $P(E) = \tfrac{1}{2}$, $P(T) = \tfrac{1}{3}$. 7.1. The same probabilities $P(s)$ are added up on both sides. 7.1. Every probability $P(s)$ with $s \in A \cap B$ is added twice on both sides; every probability $P(s)$ with $s \in A \cup B$ but $s \notin A \cap B$ is added once on both sides. --- **7.2 Independent repetition of an experiment** 7.2. The pairs $(E, T)$, $(O, T)$, $(L, T)$ are independent. The pair $(E, O)$ is exclusive. 7.2. $P(\emptyset \cap A) = P(\emptyset) = 0 = P(\emptyset)P(A)$. The set $S$ also has this property: $P(S \cap A) = P(A) = P(S)P(A)$. 7.2.P(A) = \frac{|S|^{n-1}}{|S|^n} = \frac{1}{|S|}, \quad P(B) = \frac{|S|^{n-1}}{|S|^n} = \frac{1}{|S|}, \quad P(A \cap B) = \frac{|S|^{n-2}}{|S|^n} = \frac{1}{|S|^2} = P(A)P(B).
# 8 Integers, divisors, and primes --- **8.1 Divisibility of integers** 8.1. $a = a \cdot 1 = (-a) \cdot (-1)$. 8.1. (a) even; (b) odd; (c) $a = 0$. 8.1. (a) If $b = a^m$ and $c = b^n$ then $c = a^{mn}$. (b) If $b = a^m$ and $c = a^n$ then $b + c = a(m + n)$ and $b - c = a(m - n)$. (c) If $b = a^m$ and $a, b > 0$ then $m > 0$, hence $m \ge 1$ and so $b \ge a$. (d) Trivial if $a = 0$. Assume $a \ne 0$. If $b = a^m$ and $a = b^n$ then $a = a^{mn}$, so $mn = 1$. Hence either $m = n = 1$ or $m = n = -1$. 8.1. We have $a = cn$ and $b = cm$, hence $r = b - aq = c(m - nq)$. 8.1. We have $b = a m$, $c = a q + r$ and $c = b t + s$. Hences = c - bt = (aq + r) - (am)t = (q - mt)a + r.
Since $0 \le r < a$, the remainder of the division $s : a$ is $r$. 8.1. (a) $a^2 - 1 = (a - 1)(a + 1)$. (b) $a^n - 1 = (a - 1)(a^{n-1} + \dots + a + 1)$. --- **8.3 Factorization into primes** 8.3. Yes, the number $2$. 8.3. (a) $p$ occurs in the prime factorization of $ab$, so it must occur in the prime factorization of $a$ or in the prime factorization of $b$. (b) $p \mid a(b/a)$, but $p \nmid a$, so by (a), we must have $p \mid (b/a)$. 8.3. Let $n = p_1 p_2 \dots p_k$; each $p_i \ge 2$, hence $n \ge 2^k$. 8.3. If $r_i = r_j$ then $i a - j a$ is divisible by $p$. But $i a - j a = (i - j)a$ and neither $a$ nor $i - j$ are divisible by $p$. Hence the $r_i$ are all different. None of them is $0$. Their number is $p - 1$, so every value $1, 2, \dots, p - 1$ must occur among the $r_i$. 8.3. For a prime $p$, the proof is the same as for $2$. If $n$ is composite but not a square, then there is a prime $p$ that occurs in the prime factorization of $n$ an odd number of times. We can repeat the proof by looking at this $p$. 8.3. Fact: If $\sqrt[k]{n}$ is not an integer then it is irrational. Proof: there is a prime $p$ that occurs in the prime factorization of $n$, say $t$ times, where $k \nmid t$. If (indirect assumption) $\sqrt[k]{n} = a/b$ thenn,b^k = a^k,
and so the number of times $p$ occurs in the prime factorization of the left-hand side is not divisible by $k$, while the number of times it occurs in the prime factorization of the right-hand side is divisible by $k$. A contradiction. --- **8.5 Fermat’s “Little” Theorem** 8.5.4 \nmid \binom{4}{2} = 6.
4 \nmid 2^4 - 2 - 1^4.
8.5. (a) What we need is that each of the $p$ rotated copies of a set are different. Suppose that there is a set which occurs $a$ times. Then trivially every other set occurs $a$ times. But then $a \mid p$, so we must have $a = 1$ or $p$. If all $p$ rotated copies are the same then trivially either $k = 0$ or $k = p$, which were excluded. So we have $a = 1$ as claimed. (b) Consider the set of two opposite vertices of a square. (c) If each box contains $p$ subsets of size $k$, the total number of subsets must be divisible by $p$. 8.5. We consider each number to have $p$ digits, by adding zeros at the front if necessary. We get $p$ numbers from each number $a$ by cyclic shift. These are all the same when all digits of $a$ are the same, but all different otherwise (why? the assumption that $p$ is a prime is needed here!). So we get $a^p - a$ numbers that are divided into classes of size $p$. Thus $p \mid (a^p - a)$. 8.5. Assume that $\gcd(a, p) = 1$. Consider the producta(2a)(3a)\dots((p-1)a) = (p-1)! , a^{p-1}.
Let $r_i$ be the remainder of $i a$ when divided by $p$. Then the product above has the same remainder when divided by $p$ as the product $r_1 r_2 \dots r_{p-1}$. But this product is just $(p - 1)!$. Hence $p$ is a divisor of(p - 1)! a^{p-1} - (p - 1)! = (p - 1)!(a^{p-1} - 1).
Since $p$ is a prime, it is not a divisor of $(p - 1)!$, and so it is a divisor of $a^{p-1} - 1$. --- **8.6 The Euclidean Algorithm** 8.6. $\gcd(a, b) \le a$, but $a$ is a common divisor, so $\gcd(a, b) = a$. 8.6. Let $d = \gcd(a, b)$. Then $d \mid a$ and $d \mid b$, and hence $d \mid (b - a)$. Thus $d$ is a common divisor of $a$ and $b - a$, and henced \le \gcd(a, b - a).
A similar argument shows the reverse inequality. --- # 9 Graphs --- **9.1 Even and odd degrees** 9.1. There are $2$ graphs on $2$ nodes, $8$ graphs on $3$ nodes (but only four “essentially different”), $16$ graphs on $4$ nodes (but only $11$ “essentially different”). 9.1. (a) No; sum of degrees must be even. (b) No; a node with degree $5$ must be connected to all other nodes, so we cannot have a node with degree $0$. (c) $12$. (d) $9 \cdot 7 \cdot 5 \cdot 3 \cdot 1 = 945$. 9.1. This graph, the complete graph, has $\binom{n}{2}$ edges if it has $n$ nodes. 9.1. (a) A path with $3$ nodes. (b) A star with $4$ endpoints. (c) The union of two paths with $3$ nodes. 9.1. In graph (a), the number of edges is $17$, the degrees are $9, 5, 3, 3, 2, 3, 1, 3, 2, 3$. In graph (b), the number of edges is $31$, the degrees are $9, 5, 7, 5, 8, 3, 9, 5, 7, 4$. 9.1. $\binom{10}{2} = 45$. 9.1. $2\binom{20}{2} = 2190$. 9.1. Every graph has two nodes with the same degree. Since each degree is between $0$ and $n - 1$, if all degrees were different then they would be $0, 1, 2, 3, \dots, n - 1$ (in some order). But the node with degree $n - 1$ must be connected to all the others, in particular to the node with degree $0$, which is impossible. --- **9.2 Paths, cycles, and connectivity** 9.2. There are $8$ such graphs. 9.2. The empty graph on $n$ nodes has $2^n$ subgraphs. The triangle has $18$ subgraphs. 9.2. Yes, the proof remains valid. 9.2. (a) Delete any edge from a path. (b) Consider two nodes $u$ and $v$. The original graph contains a path connecting them. If this does not go through $e$, then it remains a path after $e$ is deleted. If it goes through $e$, then let $e = xy$, and assume that the path reaches $x$ first (when traversed from $u$ to $v$). Then in the graph after $e$ is deleted, there is a path from $u$ to $x$, and also from $x$ to $y$ (the remainder of the cycle), so there is one from $u$ to $y$. But there is also one from $y$ to $v$, so there is also a path from $u$ to $v$. 9.2. (a) Consider a shortest walk from $u$ to $v$; if this goes through any nodes more than once, the part of it between two passes through this node can be deleted, to make it shorter. (b) The two paths together form a walk from $a$ to $c$. 9.2. Let $w$ be a common node of $H_1$ and $H_2$. If you want a path between nodes $u$ and $v$ in $H$, then we can take a path from $u$ to $w$, followed by a path from $w$ to $v$, to get a walk from $u$ to $v$. 9.2. Both graphs are connected. 9.2. The union of this edge and one of these components would form a connected graph that is strictly larger than the component, contradicting the definition of a component. 9.2. If $u$ and $v$ are in the same connected component, then this component, and hence $G$ too, contains a path connecting them. Conversely, if there is a path $P$ in $G$ connecting $u$ and $v$, then this path is a connected subgraph, and a maximal connected subgraph containing $P$ is a connected component containing $u$ and $v$. 9.2. Assume that the graph is not connected and let a connected component $H$ of it have $k$ nodes. Then $H$ has at most $\binom{k}{2}$ edges. The rest of the graph has at most $\binom{n-k}{2}$ edges. Then the number of edges is at most\binom{k}{2} + \binom{n-k}{2} = \binom{n-1}{2} - \frac{(k - 1)(n - k - 1)}{2} \le \binom{n-1}{2}.
--- # 10 Trees --- **10.** 10. If $G$ is a tree then it contains no cycles (by definition), but adding any new edge creates a cycle (with the path in the tree connecting the endpoints of the new edge). Conversely, if a graph has no cycles but adding any edge creates a cycle, then it is connected (two nodes $u$ and $v$ are either connected by an edge, or else adding an edge connecting them creates a cycle, which contains a path between $u$ and $v$ in the old graph), and therefore it is a tree. 11. If $u$ and $v$ are in the same connected component, then the new edge $uv$ forms a cycle with the path connecting $u$ and $v$ in the old graph. If joining $u$ and $v$ by a new edge creates a cycle, then the rest of this cycle is a path between $u$ and $v$, and hence $u$ and $v$ are in the same component. 12. Assume that $G$ is a tree. Then there is at least one path between two nodes, by connectivity. But there cannot be two paths, since then we would get a cycle (find the node $v$ where the two paths branch away, and follow the second path until it hits the first path again; follow the first path back to $v$, to get a cycle). Conversely, assume that there is a unique path between each pair of nodes. Then the graph is connected (since there is a path) and cannot contain a cycle (since two nodes on the cycle would have at least two paths between them). --- **10.1 How to grow a tree?** 10.1. Start the path from a node of degree $1$. 10.1. Any edge has only one lord, since if there were two, they would have to start from different ends, and they would then have two ways to get to the King. Similarly, an edge with no lord would have to lead to two different ways. 10.1. Start at any node $v$. If one of the branches at this node contains more than half of all nodes, move along the edge leading to this branch. Repeat. You will never backtrack because this would mean that there is an edge whose deletion results in two connected components, both containing more than half of the nodes. You will never cycle back to a node already seen because the graph is a tree. Therefore you must get stuck at a node such that each branch at this node contains at most half of all nodes. --- **10.2 Rooted trees** --- **10.3** 10.3. The number of unlabeled trees on $2,3,4,5$ nodes is $1,1,2,3$. They give rise to a total of $1,2,16,125$ labeled trees. 10.3. There are $n$ stars and $n!/2$ paths on $n$ nodes. --- **10.4 How to store a tree?** 10.4. The first is the father code of a path; the third is the father code of a star. The other two are not father codes of trees. 10.4. This is the number of possible father codes. 10.4. Define a graph on $\{1, \dots, n\}$ by connecting all pairs of nodes in the same column. If we do it backwards, starting with the last column, we get a procedure of growing a tree by adding a new node and an edge connecting it to an old node. 10.4. (a) encodes a path; (b) encodes a star; (c) does not encode any tree (there are more $0$’s than $1$’s among the first $5$ elements, which is impossible in the planar code of any tree). --- # 11 Finding the optimum --- **11.1 Finding the best tree** 11.1. Let $H$ be an optimal tree and let $G$ be the tree constructed by the pessimistic government. Look at the first step when an edge $e = uv$ of $H$ is eliminated. Deleting $e$ from $H$ we get two components; since $G$ is connected, it has an edge $f$ connecting these two components. The edge $f$ cannot be more expensive than $e$, else the pessimistic government would have chosen $f$ to eliminate instead of $e$. But then we can replace $e$ by $f$ in $H$ without increasing its cost. Hence we conclude as in the proof given above. 11.1. Very similar. 11.1. Very similar. 11.1. Take nodes $1,2,3,4$ and costs $c(12) = c(23) = c(34) = c(41) = 3$, $c(13) = 4$, $c(24) = 1$. The pessimistic government builds $(12341)$, while the best solution is $12431$. --- **11.2 Traveling Salesman** 11.2. No, because it intersects itself (see next exercise). 11.2. Replacing two intersecting edges by two other edges pairing up the same $4$ nodes, just differently, gives a shorter tour by the triangle inequality. --- # 12 Matchings in graphs --- **12.1 A dancing problem** 12.1. If every degree is $d$, then the number of edges is $d \cdot |A|$, but also $d \cdot |B|$. 12.1. (a) A triangle. (b) A star. 12.1. A graph in which every node has degree $2$ is the union of disjoint cycles. If the graph is bipartite, these cycles have even length. --- **12.3** 12.3. Let $X \subseteq A$ and let $Y$ denote the set of neighbors of $X$ in $B$. There are exactly $d|X|$ edges starting from $X$. Every node in $Y$ accommodates no more than $d$ of these; hence $|Y| \ge |X|$. --- **12.4** 12.4. On a path with $4$ nodes, we may select the middle edge. 12.4. The edges in $M$ must meet every edge in $G$, in particular every edge in the perfect matching. So every edge in the perfect matching has at most one endpoint unmatched by $M$. 12.4. The largest matching has $5$ edges. 12.4. If the algorithm terminates without a perfect matching, then the set $S$ shows that the graph is not “good”. --- **12.5** 12.5. The first graph does; the second does not.