|
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 ) \) [see Growth]: More...
#include "ADS/Contract.h"#include <cmath>#include <compare>#include <utility>#include "ADS/algorithm/impl/MasterTheorem.tpp"Go to the source code of this file.
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... | |
Namespaces | |
| namespace | ADS |
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 ) \) [see Growth]:
Two orders of growth compare as their functions do for \( n \) large: first by the base \( c \) of the exponential, then by the power \( p \) of \( n \), then by the powers \( q \) and \( r \) of the logarithms, which gives the hierarchy \( O( 1 ) \subset O( \log n ) \subset O( n ) \subset O( n \log n ) \subset O( n^2 ) \subset O( n^3 ) \subset O( 2^n ) \); note that \( 2^{\log_2 n} = n \) is a polynomial, not an exponential, and that \( n^{\log n} \) grows faster than every polynomial and slower than every \( c^n \) with \( c > 1 \), so that it has no place in this family.
The contracts [see Contract.h]: \( a \ge 1 \) and \( b > 1 \) for master(), \( a \ge 1 \) for linear(). The functions are defined in MasterTheorem.tpp.