|
ADS
Algorithms and Data Structures
|
The recurrences of divide et impera with parts of different sizes, \( T( n ) = \sum_{i=1}^k a_i T( b_i n ) + g( n ) \), \( a_i > 0 \) and \( 0 < b_i < 1 \), which the master theorem [see MasterTheorem.h] does not cover when the \( b_i \) differ, e.g., \( T( n ) = T( n / 5 ) + T( 7 n / 10 ) + n \) of the selection in linear time. More...
#include "ADS/Contract.h"#include "ADS/algorithm/MasterTheorem.h"#include <cmath>#include <utility>#include <vector>#include "ADS/algorithm/impl/AkraBazzi.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Functions | |
| double | ADS::akraBazziExponent (const std::vector< std::pair< double, double > > &ab) |
| the exponent \( p \) of Akra and Bazzi of \( T( n ) = \sum_i a_i T( b_i n ) + g( n ) \), the root of \( \sum_i a_i b_i^p = 1 \), the terms given as \( ( a_i , b_i ) \) | |
| Growth | ADS::akraBazzi (const std::vector< std::pair< double, double > > &ab, double beta, double k=0) |
| the order of \( T( n ) = \sum_i a_i T( b_i n ) + g( n ) \) with \( g( n ) = \Theta( n^\beta \log^k n ) \) | |
The recurrences of divide et impera with parts of different sizes, \( T( n ) = \sum_{i=1}^k a_i T( b_i n ) + g( n ) \), \( a_i > 0 \) and \( 0 < b_i < 1 \), which the master theorem [see MasterTheorem.h] does not cover when the \( b_i \) differ, e.g., \( T( n ) = T( n / 5 ) + T( 7 n / 10 ) + n \) of the selection in linear time.
By the theorem of Akra and Bazzi, with \( p \) the unique real root of \( \sum_i a_i b_i^p = 1 \),
\[ T( n ) = \Theta\left( n^p \left( 1 + \int_1^n \frac{g( u )}{u^{p+1}} du \right) \right) , \]
and for \( g( n ) = \Theta( n^\beta \log^k n ) \) the integral gives the cases of the master theorem with \( p \) for \( \log_b a \): \( \Theta( n^p ) \) if \( \beta < p \), \( \Theta( n^\beta \log^k n ) \) if \( \beta > p \), and for \( \beta = p \) \( \Theta( n^p \log^{k+1} n ) \) if \( k > -1 \), \( \Theta( n^p \log \log n ) \) if \( k = -1 \), \( \Theta( n^p ) \) if \( k < -1 \). The floors and the ceilings of the sizes, and perturbations of \( O( n / \log^2 n ) \), do not change the order (Leighton).
akraBazziExponent() finds \( p \) by bisection: the function \( f( p ) = \sum_i a_i b_i^p \) is strictly decreasing, so a bracket found by doubling and 200 halvings give \( p \) to the precision of a double; akraBazzi() then returns the order as a Growth.
The contracts [see Contract.h]: at least one term, \( a_i > 0 \) and \( 0 < b_i < 1 \); \( p \) is a root of the equation to \( 10^{-9} \). The functions are defined in AkraBazzi.tpp.