Master Theorem

Master Theorem

T ( n ) = a T ( n b ) + f ( n ) T(n) = aT(\frac{n}{b})+f(n) T(n)=aT(bn)+f(n)

where a ≥ 1 , b ≥ 1 a≥1,b≥1 a1,b1 be constant and f ( n ) f(n) f(n) be a function

Let T ( n ) T(n) T(n) is defined on non-negative integers by the recurrence

  • n n n is the size of the problem
  • a a a is the number of sub problems in the recursion
  • n b \frac{n}{b} bn is the size of each sub problem (Here it is assumed that all sub problems are essentially the same size)
  • f ( n ) f(n) f(n) is the time to create the sub problems and combine their results in the above procedure

There are following three cases:

  1. If f ( n ) = Θ ( n c ) f(n)=\Theta(n^c) f(n)=Θ(nc) where c < l o g b a c < log_ba c<logba then T ( n ) = Θ ( n l o g b a ) \color{red}{T(n)=\Theta(n^{log_ba})} T(n)=Θ(nlogba)
  2. If f ( n ) = Θ ( n c ) f(n)=\Theta(n^c) f(n)=Θ(nc) where c = l o g b a c=log_ba c=logba then T ( n ) = Θ ( n c l o g n ) \color{red}{T(n)=\Theta(n^clogn)} T(n)=Θ(nclogn)
  3. If f ( n ) = Θ ( n c ) f(n)=\Theta(n^c) f(n)=Θ(nc) where c > l o g b a c>log_ba c>logba then T ( n ) = Θ ( f ( n ) ) \color{red}{T(n)=\Theta(f(n))} T(n)=Θ(f(n))

Indamissible equations

T ( n ) = 2 n T ( n 2 ) + n T(n)=\color{red}{2^n}T(\frac{n}{2}) + n T(n)=2nT(2n)+n

a a a is not constant. The number of subproblems should be fixed


T ( n ) = 0.5 T ( n 2 ) + n T(n)=\color{red}{0.5}{T(\frac{n}{2})+n} T(n)=0.5T(2n)+n
a < 1 a< 1 a<1. Can’t have less than 1 subproblems


T ( n ) = 16 T ( n 2 ) − n 2 T(n)=16T(\frac{n}{2})\color{red}{-n^2} T(n)=16T(2n)n2

f ( n ) f(n) f(n) which is the combination time is not positive

你可能感兴趣的:(深度学习,python,算法)