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

  1. This is the same as

  2. (e.g. by the general formula for the binomial coefficients).


5.1 Identities in the Pascal Triangle

5.1.

5.1. The coefficient of in

is

5.1. The left-hand side counts all -element subsets of an -element set by distinguishing them according to how many elements they pick from the first .

5.1. If the largest element is , the rest can be chosen in ways.


5.2 A bird’s eye view at the Pascal Triangle

5.2. .

5.2.

(This is not easy: one looks at the difference of differences

and determines the value of where it turns negative.)

5.2. (a) is a sum with positive terms in which is only one of the terms.

(b) Assume that . Then

5.2.

5.2. Using

it is enough to find a for which . Solving for , we get that

is a good choice.

  1. (a) See (c).

(b) We prove by induction on that for ,

For this is just the theorem we already know. Let . Then

and

Hence

Since

it follows that

by the induction hypothesis.

(c)


6 Fibonacci numbers


6.1 Fibonacci’s exercise

6.1. Because we use the two previous elements to compute the next.

6.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 is divisible by , then so is ;
if has remainder when divided by , then has remainder ;
if has remainder when divided by , then has remainder ;
if has remainder when divided by , then has remainder ;
if has remainder when divided by , then has remainder .
This is then easily proved by induction on .

6.2. By induction. All of them are true for and . Assume that .

(a)

(b)

(c)

(d)

6.2. The identity is

where .

Proof by induction. True for and . Let . Assume that is odd; the even case is similar, just the last term below needs a slightly different treatment.

6.2. The “diagonal” is in fact a very long and narrow parallelogram with area . The trick depends on the fact

is very small compared to .


6.3 A formula for the Fibonacci numbers

6.3. True for . Let . Then by the induction hypothesis,

6.3. For and , if we require that is of the given form we get

Solving for and , we get

Then

follows by induction on just like in the previous problem.

6.3.


7 Combinatorial probability


7.1 Events and probabilities

7.1. The union of two events and corresponds to “ or ”.

7.1. It is the sum of some of the probabilities of outcomes, and even if we add all we get just .

7.1. , .

7.1. The same probabilities are added up on both sides.

7.1. Every probability with is added twice on both sides; every probability with but is added once on both sides.


7.2 Independent repetition of an experiment

7.2. The pairs , , are independent. The pair is exclusive.

7.2. .
The set also has this property: .

7.2.

8 Integers, divisors, and primes


8.1 Divisibility of integers

8.1. .

8.1. (a) even; (b) odd; (c) .

8.1.
(a) If and then .
(b) If and then and .
(c) If and then , hence and so .
(d) Trivial if . Assume . If and then , so . Hence either or .

8.1. We have and , hence .

8.1. We have , and . Hence

Since , the remainder of the division is .

8.1.
(a) .
(b) .


8.3 Factorization into primes

8.3. Yes, the number .

8.3.
(a) occurs in the prime factorization of , so it must occur in the prime factorization of or in the prime factorization of .
(b) , but , so by (a), we must have .

8.3. Let ; each , hence .

8.3. If then is divisible by . But and neither nor are divisible by . Hence the are all different. None of them is . Their number is , so every value must occur among the .

8.3. For a prime , the proof is the same as for . If is composite but not a square, then there is a prime that occurs in the prime factorization of an odd number of times. We can repeat the proof by looking at this .

8.3. Fact: If is not an integer then it is irrational.

Proof: there is a prime that occurs in the prime factorization of , say times, where . If (indirect assumption) then

and so the number of times occurs in the prime factorization of the left-hand side is not divisible by , while the number of times it occurs in the prime factorization of the right-hand side is divisible by . A contradiction.


8.5 Fermat’s “Little” Theorem

8.5.

8.5.
(a) What we need is that each of the rotated copies of a set are different. Suppose that there is a set which occurs times. Then trivially every other set occurs times. But then , so we must have or . If all rotated copies are the same then trivially either or , which were excluded. So we have as claimed.
(b) Consider the set of two opposite vertices of a square.
(c) If each box contains subsets of size , the total number of subsets must be divisible by .

8.5. We consider each number to have digits, by adding zeros at the front if necessary. We get numbers from each number by cyclic shift. These are all the same when all digits of are the same, but all different otherwise (why? the assumption that is a prime is needed here!). So we get numbers that are divided into classes of size . Thus .

8.5. Assume that . Consider the product

Let be the remainder of when divided by . Then the product above has the same remainder when divided by as the product . But this product is just . Hence is a divisor of

Since is a prime, it is not a divisor of , and so it is a divisor of .


8.6 The Euclidean Algorithm

8.6. , but is a common divisor, so .

8.6. Let . Then and , and hence . Thus is a common divisor of and , and hence

A similar argument shows the reverse inequality.


9 Graphs


9.1 Even and odd degrees

9.1. There are graphs on nodes, graphs on nodes (but only four “essentially different”), graphs on nodes (but only “essentially different”).

9.1.
(a) No; sum of degrees must be even.
(b) No; a node with degree must be connected to all other nodes, so we cannot have a node with degree .
(c) .
(d) .

9.1. This graph, the complete graph, has edges if it has nodes.

9.1.
(a) A path with nodes.
(b) A star with endpoints.
(c) The union of two paths with nodes.

9.1. In graph (a), the number of edges is , the degrees are
.
In graph (b), the number of edges is , the degrees are
.

9.1. .

9.1. .

9.1. Every graph has two nodes with the same degree. Since each degree is between and , if all degrees were different then they would be (in some order). But the node with degree must be connected to all the others, in particular to the node with degree , which is impossible.


9.2 Paths, cycles, and connectivity

9.2. There are such graphs.

9.2. The empty graph on nodes has subgraphs. The triangle has subgraphs.

9.2. Yes, the proof remains valid.

9.2.
(a) Delete any edge from a path.
(b) Consider two nodes and . The original graph contains a path connecting them. If this does not go through , then it remains a path after is deleted. If it goes through , then let , and assume that the path reaches first (when traversed from to ). Then in the graph after is deleted, there is a path from to , and also from to (the remainder of the cycle), so there is one from to . But there is also one from to , so there is also a path from to .

9.2.
(a) Consider a shortest walk from to ; 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 to .

9.2. Let be a common node of and . If you want a path between nodes and in , then we can take a path from to , followed by a path from to , to get a walk from to .

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 and are in the same connected component, then this component, and hence too, contains a path connecting them. Conversely, if there is a path in connecting and , then this path is a connected subgraph, and a maximal connected subgraph containing is a connected component containing and .

9.2. Assume that the graph is not connected and let a connected component of it have nodes. Then has at most edges. The rest of the graph has at most edges. Then the number of edges is at most


10 Trees


10.

  1. If 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 and are either connected by an edge, or else adding an edge connecting them creates a cycle, which contains a path between and in the old graph), and therefore it is a tree.

  2. If and are in the same connected component, then the new edge forms a cycle with the path connecting and in the old graph. If joining and by a new edge creates a cycle, then the rest of this cycle is a path between and , and hence and are in the same component.

  3. Assume that 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 where the two paths branch away, and follow the second path until it hits the first path again; follow the first path back to , 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 .

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 . 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 nodes is . They give rise to a total of labeled trees.

10.3. There are stars and paths on 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 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 ’s than ’s among the first elements, which is impossible in the planar code of any tree).


11 Finding the optimum


11.1 Finding the best tree

11.1. Let be an optimal tree and let be the tree constructed by the pessimistic government. Look at the first step when an edge of is eliminated. Deleting from we get two components; since is connected, it has an edge connecting these two components. The edge cannot be more expensive than , else the pessimistic government would have chosen to eliminate instead of . But then we can replace by in 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 and costs
, , .
The pessimistic government builds , while the best solution is .


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 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 , then the number of edges is , but also .

12.1. (a) A triangle. (b) A star.

12.1. A graph in which every node has degree is the union of disjoint cycles. If the graph is bipartite, these cycles have even length.


12.3

12.3. Let and let denote the set of neighbors of in . There are exactly edges starting from . Every node in accommodates no more than of these; hence .


12.4

12.4. On a path with nodes, we may select the middle edge.

12.4. The edges in must meet every edge in , in particular every edge in the perfect matching. So every edge in the perfect matching has at most one endpoint unmatched by .

12.4. The largest matching has edges.

12.4. If the algorithm terminates without a perfect matching, then the set shows that the graph is not “good”.


12.5

12.5. The first graph does; the second does not.