Use Master formula

 master equation (also known as the main method) is to use divide and conquer strategy to address the complexity of the analysis of time frequently used (added: recursive solution divide and conquer strategy, there are two common methods called the substitution method and recursive tree law), divide and conquer strategy to use recursion to solve the problem in three steps, namely decomposition, resolve and merge, so the form of the main methods:

T [n] = aT[n/b] + f (n)或直接记为T [n] = aT[n/b] + T (N^d)

Where a> = 1 and b> 1 is a constant, n denotes the size of the problem, a represents the number of sub-problems of recursion is generated, b represents the size of each recursive original is a 1 / b of, f (n) an exploded and the cost of the merger and to spend.

Solution:
① When d <time log (b, a), the time complexity is O (n-^ (logb A))
② When d = log (b, a) , the time complexity is O ((n ^ d) logN *)
③ when d> when the log (b, a), the time complexity is O (n ^ d)

Guess you like

Origin www.cnblogs.com/FansticSee/p/11278454.html