## B.5 Proofs of Theorems
The following lemma is needed to prove [Theorem B.1](LiB0103.html#1391).
Lemma B.1**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**Suppose we have the homogeneous linear recurrence
![](https://box.kancloud.cn/9ba718129d2158a14247a1244f94a9bf_266x19.jpg)
If *r*1 is a root of the characteristic equation
![](https://box.kancloud.cn/2a315ae4c7832c8aab6f1cfa53bca0ba_234x23.jpg)
then
![](https://box.kancloud.cn/de9672e43142e34b9b86f18979199081_62x21.jpg)
is a solution to the recurrence.
Proof: If, for *i* = *n – k*, …, *n*, we substitute *ri*1 for *ti* in the recurrence, we obtain
![](https://box.kancloud.cn/c482efed5498a05aa54c1541ab4fdd5e_400x101.jpg)
Therefore, *rn*1 is a solution to the recurrence.
**![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**
Proof of [Theorem B.1](LiB0103.html#1391) It is not hard to see that, for a linear homogeneous recurrence, a constant times any solution and the sum of any two solutions are each solutions to the recurrence. We can therefore apply [Lemma B.1](#ap-bex36) to conclude that, if
![](https://box.kancloud.cn/0d4f4575079f7d384523b7f78dd861c6_103x17.jpg)
are the *k* distinct roots of the characteristic equation, then
![](https://box.kancloud.cn/2bb0a37f00f3a076027ce5b296303b14_197x23.jpg)
where the *ci* terms are arbitrary constants, is a solution to the recurrence. Although we do no show it here, one can prove that these are the only solutions.
![](https://box.kancloud.cn/485bc67a7beadb016ac9d44f235f6e03_27x27.jpg) Proof of [Theorem B.2](LiB0103.html#1397) We prove the case where the multiplicity *m* equals 2. The case of a larger *m* is a straightforward generalization. Let *r*1 be a root of multiplicity 2. Set
![](https://box.kancloud.cn/8a0bfae20b506e4cbb492113a2832a2f_400x65.jpg)
where *q*′ (*r*) means the first derivative. If we subsitute *iri*1 for *ti* in the recurrence, we obtain *u* (*r*1). Therefore, if we can show that *u* (*r*1) = 0, we can conclude that *tn* = *nrn*1 is a solution to the recurrence, and we are done. To this end, we have
![](https://box.kancloud.cn/6b1436661de99088b58dc750b338c77c_348x87.jpg)
Therefore, to show that *u* (*r*1) = 0, we need only show that *p* (*r*1) and *p*′ (*r*1) both equal 0. We show this as follows. Because *r*1 is a solution of multiplicity 2 of the characteristic equation *p* (*r*), there exists a *v* (*r*) such that
![](https://box.kancloud.cn/fd0bc2c467e4563ec1f372303ad3cdc2_176x25.jpg)
Therfore,
![](https://box.kancloud.cn/f44e5e3efd69e1ccb332161f43dcf294_317x26.jpg)
and *p* (*r*1) and *p*′ (*r*1) both equal 0. This completes the proof.
![](https://box.kancloud.cn/485bc67a7beadb016ac9d44f235f6e03_27x27.jpg) Proof of [Theorem B.4](LiB0105.html#1434) We obtain the proof for "big *O*." Proof for Ω and Θ can be established in a similar manner. Because *T* (*n*) ∊ *O* (*f* (*n*) for all *n* such that *n* is a power of *b*, there exist a positive *c*1 and a nonnegative integer *N*1 such that, for *n* > *N*1 and *n* a power of *b*,
![](https://box.kancloud.cn/a18b926009af284a9320d8874382670f_382x24.jpg)
For any positive integer *n*, there exists a unique *k* such that
![](https://box.kancloud.cn/5c26d040b167a1984b101ec200e93181_364x26.jpg)
It is possible to show, in the case of a smooth function, that if *b* ≥ 2, then
![](https://box.kancloud.cn/36ac55e3ee94fceb333dbfa03cd4d37e_148x22.jpg)
That is, if this condition holds for 2, it holds for any *b* > 2. Therefore, there exist a positive constant *c*2 and a nonnegative integer *N*2 such that, for *n* > *N*2,
![](https://box.kancloud.cn/3421bfad321a2bfeb3efb61b6aa8a432_134x22.jpg)
Therefore, if *bk*≥ *N*2,
![](https://box.kancloud.cn/6cbaf9f7943117df3c50722dfe2e2372_400x31.jpg)
Because *T* (*n*) and *f* (*n*) are both eventually nondecreasing, there exists an *N*3, such that, for *m* > *n* > *N*3,
![](https://box.kancloud.cn/a99d23d683ba9af13ec9b7b5bb5ef0cf_400x22.jpg)
Let *r* be so large that
![](https://box.kancloud.cn/52a980e0155d1d73b6d29c4e6ecfad86_184x23.jpg)
If *n* > *br* and *k* is the value corresponding to *n* in [Inequality B.7](#ap-beqn07), then
![](https://box.kancloud.cn/329b5e77e0feeb1c4477b5586676c6a0_64x23.jpg)
Therefore, by [Inequalities B.6](#ap-beqn06), [B.7](#ap-beqn07), [B.8](#ap-beqn08), and [B.9](#ap-beqn09), for *n* > *br*,
![](https://box.kancloud.cn/d06c378522fec444328fadaa00ef9b7b_400x24.jpg)
which means that
![](https://box.kancloud.cn/e32244c537be060649378aae8aa9c0c5_143x22.jpg)
- Table of Contents
- BackCover
- Foundations of Algorithms Using C++ Pseudocode, Third Edition
- Preface
- Chapter Contents
- Pedagogy
- Course Outlines
- Acknowledgments
- Errors
- Chapter 1: Algorithms - Efficiency, Analysis, and Order
- 1.2 The Importance of Developing Efficient Algorithms
- 1.3 Analysis of Algorithms
- 1.4 Order
- 1.5 Outline of This Book
- Exercises
- Chapter 2: Divide-and-Conquer
- 2.1 Binary Search
- 2.2 Mergesort
- 2.3 The Divide-and-Conquer Approach
- 2.4 Quicksort (Partition Exchange Sort)
- 2.5 Strassen's Matrix Multiplication Algorithm
- 2.6 Arithmetic with Large Integers
- 2.7 Determining Thresholds
- 2.8 When Not to Use Divide-and-Conquer
- Exercises
- Chapter 3: Dynamic Programming
- 3.1 The Binomial Coefficient
- 3.2 Floyd's Algorithm for Shortest Paths
- 3.3 Dynamic Programming and Optimization Problems
- 3.4 Chained Matrix Multiplication
- 3.5 Optimal Binary Search Trees
- 3.6 The Traveling Salesperson Problem
- Exercises
- Chapter 4: The Greedy Approach
- 4.1 Minimum Spanning Trees
- 4.2 Dijkstra's Algorithm for Single-Source Shortest Paths
- 4.3 Scheduling
- 4.4 Huffman Code
- 4.5 The Greedy Approach versus Dynamic Programming: The Knapsack Problem
- Exercises
- Chapter 5: Backtracking
- 5.2 The n-Queens Problem
- 5.3 Using a Monte Carlo Algorithm to Estimate the Efficiency of a Backtracking Algorithm
- 5.4 The Sum-of-Subsets Problem
- 5.5 Graph Coloring
- 5.6 The Hamiltonian Circuits Problem
- 5.7 The 0-1 Knapsack Problem
- Exercises
- Chapter 6: Branch-and-Bound
- 6.1 Illustrating Branch-and-Bound with the 0 - 1 Knapsack problem
- 6.2 The Traveling Salesperson Problem
- 6.3 Abductive Inference (Diagnosis)
- Exercises
- Chapter 7: Introduction to Computational Complexity - The Sorting Problem
- 7.2 Insertion Sort and Selection Sort
- 7.3 Lower Bounds for Algorithms that Remove at Most One Inversion per Comparison
- 7.4 Mergesort Revisited
- 7.5 Quicksort Revisited
- 7.6 Heapsort
- 7.6.1 Heaps and Basic Heap Routines
- 7.6.2 An Implementation of Heapsort
- 7.7 Comparison of Mergesort, Quicksort, and Heapsort
- 7.8 Lower Bounds for Sorting Only by Comparison of Keys
- 7.8.1 Decision Trees for Sorting Algorithms
- 7.8.2 Lower Bounds for Worst-Case Behavior
- 7.8.3 Lower Bounds for Average-Case Behavior
- 7.9 Sorting by Distribution (Radix Sort)
- Exercises
- Chapter 8: More Computational Complexity - The Searching Problem
- 8.1 Lower Bounds for Searching Only by Comparisons of Keys
- 8.2 Interpolation Search
- 8.3 Searching in Trees
- 8.4 Hashing
- 8.5 The Selection Problem: Introduction to Adversary Arguments
- Exercises
- Chapter 9: Computational Complexity and Interactability - An Introduction to the Theory of NP
- 9.2 Input Size Revisited
- 9.3 The Three General Problem Categories
- 9.4 The Theory of NP
- 9.5 Handling NP-Hard Problems
- Exercises
- Chapter 10: Number-Theoretic Algorithms
- 10.1 Number Theory Review
- 10.2 Computing the Greatest Common Divisor
- 10.3 Modular Arithmetic Review
- 10.4 Solving Modular Linear Equations
- 10.5 Computing Modular Powers
- 10.6 Finding Large Prime Numbers
- 10.7 The RSA Public-Key Cryptosystem
- Exercises
- Chapter 11: Introduction to Parallel Algorithms
- 11.1 Parallel Architectures
- 11.2 The PRAM Model
- Exercises
- Appendix A: Review of Necessary Mathematics
- A.2 Functions
- A.3 Mathematical Induction
- A.4 Theorems and Lemmas
- A.5 Logarithms
- A.6 Sets
- A.7 Permutations and Combinations
- A.8 Probability
- Exercises
- Appendix B: Solving Recurrence Equations - With Applications to Analysis of Recursive Algorithms
- B.2 Solving Recurrences Using the Characteristic Equation
- B.3 Solving Recurrences by Substitution
- B.4 Extending Results for n, a Power of a Positive Constant b, to n in General
- B.5 Proofs of Theorems
- Exercises
- Appendix C: Data Structures for Disjoint Sets
- References
- Index
- Index_B
- Index_C
- Index_D
- Index_E
- Index_F
- Index_G
- Index_H
- Index_I
- Index_J
- Index_K
- Index_L
- Index_M
- Index_N
- Index_O
- Index_P
- Index_Q
- Index_R
- Index_S
- Index_T
- Index_U
- Index_V
- Index_W-X
- Index_Y
- Index_Z
- List of Figures
- List of Tables
- List of Algorithms, Examples, and Theorems
- List of Sidebars