ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
AkraBazzi.h File Reference

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 ) \)

Detailed description

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.

See also
A. Montresor, Algoritmi e Strutture Dati, 2025, section 2.9, https://algoritmicamente.it/materiali/libro/capitoli/cap02.pdf
M. Akra, L. Bazzi, On the solution of linear recurrence equations, Computational Optimization and Applications 10(2), 195-210, 1998, doi:10.1023/A:1018373005182
T. Leighton, Notes on better master theorems for divide-and-conquer recurrences, MIT, 1996
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa