Template Function ADS::findPeak

Function Documentation

template<class T, class C = std::less<>>
std::size_t ADS::findPeak(const std::vector<T> &A, C less = C())

findPeak(): the place r of an item of A not smaller than its neighbours, by a binary search; \( \lceil \log_2 n \rceil \) comparisons

Pre:

A is not empty

Post:

A[ r ] not smaller than A[ r - 1 ] and A[ r + 1 ], where they are