The method of "algorithm review" to solve recursive formula

Source: Internet
Author: User

the method of solving recursive type

"Substituting Law"

    • The solution of substituting method is divided into two steps:
      • The form of guessing solutions
      • By using the mathematical induction method to find out the constant c of the solution, and prove the correctness, the key step is to use the guessed solution into the recursive formula.
    • Make good guesses (no general method, only experience)
      • Similar to the solution you have seen, guess it.
      • The upper and lower bounds of the first pass are more relaxed, and the guessing range is reduced. We can start with the nether Ω (N), the upper bound O (n^2), and then gradually converge to (NLOG2N)
    • Detail correction
      • Sometimes the guessing solution is correct, but the mathematical induction does not directly prove its details, because the mathematical induction is not strong enough to prove its details.
      • a lower order can be subtracted from the guess solution to satisfy the mathematical induction method.
    • Avoid traps
      • Similar to the summation mathematical induction method, it is proved that the use of asymptotic notation is prone to error.
      • such as: proof O (n) must be strictly proved ≤CN, can not be said to change to do cn+n
    • Variable transformation
      • Sometimes changing variables can make an unknown recursive into a familiar formula. For example:

"Substituting law questions"

"Recursive Tree Method"

    • Recursive trees are best used to generate good guesses, and then use the surrogate method to verify that the guesses are correct.
    • Need attention:
      • Number of iterations required to reach the boundary condition
      • The and formula in the iterative process. If the form of the solution has been estimated in the iterative process, it can also be used in the method of substituting

"Recursive tree Law Question"

"Master principle"

    • The master theorem is also called the principal theorem. It provides a way to represent recursive relationships by means of asymptotic notation. The recursive equation can be solved easily by applying the master theorem.

theorem 4.1 (principal theorem) makes a≥1 and b>1 a constant, f (n) is a function, and T (n) is a recursive formula defined on a nonnegative integer:

T (n) = at (n/b) + f (n)

Which we will explain n/b as. Then T (n) has the following asymptotic bounds:

  

The three cases of the main theorem, after analysis, can be found to be the F (n) and comparison.

The first case is greater, the second case is equal to f (n), and the third case is F (n) greater.

"Main theorem Example"

The method of "algorithm review" to solve recursive formula

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.