🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## Exercises #### Section B.1 1. Use induction to verify the candidate solution to each of the following recurrence equations. 1. *tn* = 4*t**n* − 1 for *n* > 1 *t*1 = 3 The candidate solution is *tn* = 3(4*n* − 1). 2. *tn* = *t**n* − 1 + 5 for *n* > 1 *t*1 = 2 The candidate solution is *t**n* = 5*n* − 3. 3. *t**n* = *t**n* − 1 + *n* for *n* > 1 *t*1 = 1 The candidate solution is *tn* = 3 (4*n*-1) 4. *t**n* = *t**n* − 1 + *n*2 for *n* > 1 *t*1 = 1 The candidate solution is ![](https://box.kancloud.cn/2e4ac323875404b8fdcbeffd3a4ccff6_190x47.jpg) 5. ![](https://box.kancloud.cn/70c1884a82a7b9bf715b416ebf47c175_313x48.jpg) *t*1 = ½ The candidate solution is ![](https://box.kancloud.cn/ffe21441cc512c6cd6b097c9b8eb07d2_111x46.jpg) 6. *t**n* = 3*t**n* − 1 + 2*n* for *n* > 1 *t*1 = 1 The candidate solution is *t**n* = 5 (3*n* − 1) − 2*n* + 1. 7. *t**n* = 3*t**n*/2 + *n* for *n* > 1, *n* a power of 2 *t*1 = ½ The candidate solution is ![](https://box.kancloud.cn/c0aac28ed06dfca82624344756ee91ef_133x25.jpg) 8. *t**n* = *nt**n* − 1 for *n* > 0 *t*0 = 1 The candidate solution is *tn* = *n*!. 2. Write a recurrence equation for the *n*th term of the sequence 2, 6, 18, 54, …, and use induction to verify the candidate solution *sn* = 2 (3*n*-1). 3. The number of moves (*mn* for *n* rings) needed in the Towers of Hanoi problem (see Exercise 17 in [Chapter 2](LiB0014.html#141)) is given by the following recurrence equation ![](https://box.kancloud.cn/78b74168c76d198b1baa3648f8bc205c_243x46.jpg) Use induction to show that the solution to this recurrence equation is *mn* = 2*n* - 1. 4. The following algorithm returns the position of the largest element in the array *S*. Write a recurrence equation for the number of comparisons *tn* needed to find the largest element. Use induction to show that the equation has the solution *tn* = *n* - 1. ``` index max_position (index low, index high) { index position; if (low == high) return low; else{ position = max_position (low + 1, high); if (S[low] > S[position]) position = low; return position; } } ``` The top-level call is *max\_position* (1, *n*). 5. The ancient Greeks were very interested in sequences resulting from geometric shapes such as the following traingular numbers: ![](https://box.kancloud.cn/61564b00cc3a5a240cf2fb69da560b37_292x53.jpg) Write a recurrence equation for the *n*th term in this sequence, guess a solution, and use induction to verify your solution. 6. Into how many regions do *n* lines divide a plane so that every pair of lines intersect, but no more than two lines intersect at a common point? Write a recurrence equation for the number of regions for *n* lines, guess a solution for your equation, and use induction to verify your solution. 7. Show that ![](https://box.kancloud.cn/0ebab3cce21a90c1bb5044ec680808d0_152x46.jpg) is the solution to the following recurrence equation: ![](https://box.kancloud.cn/9a83b3498fa11362564897da1bdeb88e_400x67.jpg) 8. Write and implement an algorithm that computes the value of the following recurrence, and run it using different problem instances. Use the results to guess a solution for this recurrence, and use induction to verify to your solution. ![](https://box.kancloud.cn/2ab91c360d4051e1b9bab67492bf3794_257x46.jpg) #### Section B.2 1. Indicate which recurrence eqations in the problems for [Section B.1](LiB0102.html#1371) fall into each of the following categories. 1. Linear equations 2. Homogeneous equations 3. Equations with constant coefficients 2. Find the characteristic equations for all of the recurrence equations in [Sections B.1](#ap-blev3sec1) that are linear with constant coefficients. 3. Show that if *f* (*n*) and *g* (*n*) are both solutions to a linear homogeneous recurrence equation with constant coefficients, then so is *c* × *f* (*n*) + *d × g* (*n)*, where *c* and *d* are constants. 4. Solve the following recurrence equations using the characteristic equation. 1. ![](https://box.kancloud.cn/6761ba15b0621c7ae25939e61a0ddd95_262x68.jpg) 2. ![](https://box.kancloud.cn/19e8ba0eb6a0c5980acf617ac0e406e1_301x72.jpg) 3. ![](https://box.kancloud.cn/a0fe9f88ec51978c4360cc38bc995045_305x75.jpg) 4. ![](https://box.kancloud.cn/4955cb004e2acb44b5e7fc37c75ed8a2_384x75.jpg) 5. Complete the solution to the recurrence equation given in [Example B.15](LiB0103.html#1410). 6. Complete the solution to the recurrence equation given in [Example B.16](LiB0103.html#1412). 7. Solve the following recurrence equations using the characteristic equation. 1. ![](https://box.kancloud.cn/4f56a13572a0919665daaf8e76dea386_261x72.jpg) 2. ![](https://box.kancloud.cn/e6ef22bfe63333103164ea4b28f28736_328x97.jpg) 3. ![](https://box.kancloud.cn/6fcf1aed581b5cab9692abeac46f1b71_333x71.jpg) 4. ![](https://box.kancloud.cn/ffe2cf12631e4370e2cc78301bb845b7_380x73.jpg) 8. Complete the solution to the recurrence equation given in [Example B.17](LiB0103.html#1414). 9. Show that the recurrence equation ![](https://box.kancloud.cn/9309bef52382df30735cb3a8828baedb_358x74.jpg) can be written as ![](https://box.kancloud.cn/e672e67f68de00534d10af97377eb418_265x47.jpg) 10. Solve the recurrence equation in Exercise 17. The solution gives the number of derangements (nothing is in its right place) of *n* objects. 11. Solve the following recurrence equations using the characteristic equation. 1. ![](https://box.kancloud.cn/246b8ace31929e60e80747b6a19c2e6d_400x56.jpg) 2. ![](https://box.kancloud.cn/da7ab6f798b16b7f7443b6bf9dfd7241_400x58.jpg) 3. ![](https://box.kancloud.cn/595be313beef4bec9dd05b4c32400a39_345x47.jpg) 4. ![](https://box.kancloud.cn/4908d7410fd63f895ffd9eecf9bc0faa_400x60.jpg) 5. ![](https://box.kancloud.cn/3cf5e4a61a4cfb7919edb6c9cbc66bb9_384x50.jpg) #### Section B.3 1. Solve the recurrence equations in Exercise 1 using the substitution method. #### Section B.4 1. Show that 1. *f* (*n*) = *n*3 is a strictly increasing function. 2. *g* (*n*) = 2*n*3 - 6*n*2 is an eventually nondecreasing function. 2. What can we say about a function *f* (*n*) that is both nondecreasing and nonincreasing for all values of *n*? 3. Show that the following functions are smooth. 1. *f* (*n*) = *n* lg *n* 2. *g* (*n*) = *nk*, for all *k* ≥ 0. 4. Assuming in each case that *T* (*n*) is eventually nondecreasing, use [Theorem B.5](LiB0105.html#1438) to determine the order of the following recurrence equations. 1. ![](https://box.kancloud.cn/0c9b433dd4403828f4fec09694c95cf1_400x59.jpg) 2. ![](https://box.kancloud.cn/260a13831ab65927e8e5c9c8f36294a0_400x57.jpg) 3. ![](https://box.kancloud.cn/28ec64b189f3af7c2fcf6620d9a8881c_400x56.jpg) 5. Assuming in each case that *T* (*n*) is eventually nondecreasing, use [Theorem B.6](LiB0105.html#1443) to determine the order of the following recurrence equations: 1. ![](https://box.kancloud.cn/631410b8cd15a5fc4d4eebd5f6ecd8ce_400x57.jpg) 2. ![](https://box.kancloud.cn/61e9acb4386ff49bcf10a054ab84ff3c_400x58.jpg) 6. We know that the recurrence ![](https://box.kancloud.cn/f4978ccd1293d67d8027481f867675f5_400x60.jpg) has solution ![](https://box.kancloud.cn/f352fdd4593defb3cc83e54e5d8894dd_145x26.jpg) in the case *a* > *c*, provided that *g* (*n*) ∊ Θ (*n*). Prove that the recurrence has the same solution if we assume that ![](https://box.kancloud.cn/92fc4a08832fe721ec4e27e28b03d17e_255x25.jpg)