Introduction to Algorithms Solving Recursive Summary

1 Main method to solve

几种方法是按照f(n)与log b/a的大小划分的。

#

2 Recursion tree solution

2.1 Understand several important concepts

  • cost per layer
  • total number of leaves
  • layers
  • The cost of recursively calling the top level
  • a and b

3 Master's theorem solution

4. Substitution method to solve

4.1 Solving steps:

1. Guess the form of
the solution 2. Use mathematical induction to find out the Changshu in the solution, and prove that the explanation is correct.

4.2 Points to note:

1. Make good predictions
2. Subtle details
3. Avoid pitfalls
4. Change variables

Overview

在递归树中,每个结点表示一个单一子问题的代价,子问题对应某次递归函数的调用。我们将树中每层求和,得到每层代价,然后将所有层的代价求和,求得了所有层次递归调用的总代价。
若递归的子问题中a=3,b=4,f(n)=n^2
T() 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325481319&siteId=291194637