Data Structures & Algorithms in C++
Goodrich, Tamassia, Mount and Goldwasser
|
Code from the chapter "Algorithm Analysis". More...
Functions | |
bool | is_disjoint1 (const std::vector< int > &groupA, const std::vector< int > &groupB, const std::vector< int > &groupC) |
bool | is_disjoint2 (const std::vector< int > &groupA, const std::vector< int > &groupB, const std::vector< int > &groupC) |
int | example1 (const std::vector< int > &seq) |
int | example2 (const std::vector< int > &seq) |
int | example3 (const std::vector< int > &seq) |
int | example4 (const std::vector< int > &seq) |
int | example5 (const std::vector< int > &first, const std::vector< int > &second) |
int | find_first (const std::vector< int > &data, int val) |
int | find_max (const std::vector< int > &data) |
std::vector< double > | prefix_averages1 (const std::vector< double > &x) |
std::vector< double > | prefix_averages2 (const std::vector< double > &x) |
bool | is_unique1 (const std::vector< int > &data) |
bool | is_unique2 (const std::vector< int > &data) |
Code from the chapter "Algorithm Analysis".
int dsac::analysis::example5 | ( | const std::vector< int > & | first, |
const std::vector< int > & | second | ||
) |
Returns first index j such that data[j] == val, or -1 if no such element
data | a vector of integers |
val | the target value |
Returns the maximum value of a nonempty vector of integers
data | a nonempty vector of integers |
bool dsac::analysis::is_disjoint1 | ( | const std::vector< int > & | groupA, |
const std::vector< int > & | groupB, | ||
const std::vector< int > & | groupC | ||
) |
Returns true if there is no element common to all three groups
groupA | a vector of integers |
groupB | a vector of integers |
groupC | a vector of integers |
bool dsac::analysis::is_disjoint2 | ( | const std::vector< int > & | groupA, |
const std::vector< int > & | groupB, | ||
const std::vector< int > & | groupC | ||
) |
Returns true if there is no element common to all three groups
groupA | a vector of integers |
groupB | a vector of integers |
groupC | a vector of integers |
bool dsac::analysis::is_unique1 | ( | const std::vector< int > & | data | ) |
Returns true if there are no duplicate elements in the vector
data | a vector of integers |
bool dsac::analysis::is_unique2 | ( | const std::vector< int > & | data | ) |
Returns true if there are no duplicate elements in the vector
data | a vector of integers |
std::vector< double > dsac::analysis::prefix_averages1 | ( | const std::vector< double > & | x | ) |
Computes prefix average such that for each j, result a[j] equals the average of x[0], ..., x[j].
x | a vector of doubles |
std::vector< double > dsac::analysis::prefix_averages2 | ( | const std::vector< double > & | x | ) |
Computes prefix average such that for each j, result a[j] equals the average of x[0], ..., x[j].
x | a vector of doubles |