Introduction to Algorithms - A Creative Approach: Chapter 2
Exercise 2.1
Prove is divisible by for all natural numbers and .
Proof: The proof is by induction on .
Induction Hypothesis: is divisible by for all natural numbers and all .
The case for and is trivial. Assume the claim is true for and consider .
All terms are divisible by by the induction hypothesis, therefore the expression is divisible by .
Exercise 2.9
Prove by induction that a number, given in its decimal representation, is divisible by 3 if and only if the sum of its digits is divisible by 3.
Theorem: A number , given in its decimal representation, is congruent to if and only if the sum of its digits is congruent to .
Proof: The claim is easily verified for small numbers.
Assume the theorem is true for and consider . The difference between the decimal representation of and is only in the last digit, unless the last digit of is 9. Consider the following two cases:
- The last digit of is not 9. Then both and the sum of the digits of are incremented by 1 and the relation holds.
- The last digit of is 9. Then we change the 9 to 0 and add 1 to the second to last digit. Changing the 9 to a 0 doesn’t change the relation, as both and is 0. Adding 1 to the second to last digit increases both the sum of the digits by 1 and the number by 1 and the relation holds. If the second to last digit is also a 9, we repeat this case.
Exercise 2.12
Prove, that for all ,
Proof: The proof is by induction on .
Induction Hypothesis: The theorem is true for all such that .
The theorem is true for because
Consider . We’ll rearrange the left side of the equation.
We know by the induction hypothesis that . We only need to show that the remaining part of the equation is greater than or equal to zero. That is,
Exercise 2.13
This problem was marked as “especially challenging”, a sentiment that I agree with. I used the friendly folks at Math.StackExchange to solve this problem. Proving the sum of fractions has an odd numerator and an even denominator.
Prove that, for all
where is an odd number and is an even number.
Proof: The proof is by strong induction on
Base Case:
Assume the theorem is true for all such . We first break the equation apart by grouping fractions with even denominators and those with odd denominators.
For the odd denominators, we have: , where is the largest odd number less than or equal to .
We know must be odd, because all of the denominators are odd. We can ignore .
For the even denominators, we have: , where is the largest even number less than or equal to .
We can modify to fit induction hypothesis by factoring out from each element, . By the induction hypothesis, is odd and is even.
We know is even, so is even and both and are odd, so is odd. Hence the numerator is odd. is even, so the denominator is even.
Exercise 2.19
Prove that the regions formed by circles in the plan can be colored with two colors such that any neighboring regions are colored differently.
Proof: The proof is by induction on .
Base Case: One circle only needs one color.
Assume the theorem is true for and consider .
Let’s first remove the circle for a bit. Now we have a total of circles, with the circle taking the place of the circle. By the inductive hypothesis, we have a valid coloring.
Now, lets consider what happens when we re-add the circle. There are three cases:
- The circle doesn’t intersect any other circle. Then we can simply pick our favorite color and call it good.
- The circle intersects some circles. We can color the circle by inverting colors based on the number of overlapping circles. If the number of overlaps is even, then we invert that region. If the number of overlaps is odd, we leave the color the same. A region with an even number of overlaps cannot be adjacent to a region with an odd number of overlaps. I can’t figure out how to explain why this is true.