|
ADS
Algorithms and Data Structures
|
The solutions of the recurrences of section 2.9, as orders of growth \( \Theta( c^n n^p \log^q n ( \log \log n )^r ) \). More...
Files | |
| file | ADS/algorithm/MasterTheorem.h |
| The solutions of the recurrences of section 2.9, as orders of growth \( \Theta( c^n n^p \log^q n ( \log \log n )^r ) \) [see Growth]: | |
Classes | |
| struct | ADS::Growth |
| the order \( c^n n^p \log^q n ( \log \log n )^r \), and whether it is only an upper bound More... | |
Functions | |
| Growth | ADS::master (double a, double b, double beta, double k=0) |
| the order of \( T( n ) = a T( n / b ) + \Theta( n^\beta \log^k n ) \); \( \log_b a \) within \( 10^{-12} \) of an integer is taken as that integer (\( \log_{10} 1000 \) is 3, not 2.9999999999999996), and with \( \beta = \log_b a \) the power is \( \beta \) | |
| Growth | ADS::linear (double a, double beta) |
| the order of \( T( n ) = \sum_i a_i T( n - i ) + \Theta( n^\beta ) \), \( a = \sum_i a_i \) | |
The solutions of the recurrences of section 2.9, as orders of growth \( \Theta( c^n n^p \log^q n ( \log \log n )^r ) \).
The definitions, the invariants and the costs of the area are in Theory of other algorithms.
|
inline |
the order of \( T( n ) = \sum_i a_i T( n - i ) + \Theta( n^\beta ) \), \( a = \sum_i a_i \)
In pseudocode (Theorem 2.5 of section 2.9):
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{linear}( a , \beta )\quad \triangleright \ T( n ) = a T( n - 1 ) + \Theta( n^\beta ) \cr 2 & \quad \textbf{if}\ a > 1\ \textbf{then return}\ O( a^n n^\beta )\quad \triangleright\ \text{a bound from above only} \cr 3 & \quad \textbf{return}\ \Theta( n^{\beta + 1} )\quad \triangleright\ a = 1 \end{array}} \]
|
inline |
the order of \( T( n ) = a T( n / b ) + \Theta( n^\beta \log^k n ) \); \( \log_b a \) within \( 10^{-12} \) of an integer is taken as that integer (\( \log_{10} 1000 \) is 3, not 2.9999999999999996), and with \( \beta = \log_b a \) the power is \( \beta \)
In pseudocode (Theorem 2.4 of section 2.9):
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{master}( a , b , \beta , k )\quad \triangleright\ T( n ) = a T( n / b ) + \Theta( n^\beta \log^k n ) \cr 2 & \quad \alpha \gets \log_b a\quad \triangleright \ \text{the exponent of the leaves of the recursion} \cr 3 & \quad \textbf{if}\ \alpha > \beta\ \textbf{then return}\ \Theta( n^\alpha ) \cr 4 & \quad \textbf{if}\ \alpha < \beta\ \textbf{then return}\ \Theta( n^\beta \log^k n ) \cr 5 & \quad \textbf{if}\ k < -1\ \textbf{then return}\ \Theta( n^\alpha )\quad \triangleright\ \alpha = \beta \text{ from here on} \cr 6 & \quad \textbf{if}\ k = -1\ \textbf{then return}\ \Theta( n^\alpha \log \log n ) \cr 7 & \quad \textbf{return}\ \Theta( n^\alpha \log^{k+1} n ) \end{array}} \]