Data Structures & Algorithms in C++
Goodrich, Tamassia, Mount and Goldwasser
Loading...
Searching...
No Matches
Functions
dsac::analysis Namespace Reference

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)
 

Detailed Description

Code from the chapter "Algorithm Analysis".

Function Documentation

◆ example1()

int dsac::analysis::example1 ( const std::vector< int > &  seq)

◆ example2()

int dsac::analysis::example2 ( const std::vector< int > &  seq)

◆ example3()

int dsac::analysis::example3 ( const std::vector< int > &  seq)

◆ example4()

int dsac::analysis::example4 ( const std::vector< int > &  seq)

◆ example5()

int dsac::analysis::example5 ( const std::vector< int > &  first,
const std::vector< int > &  second 
)

◆ find_first()

int dsac::analysis::find_first ( const std::vector< int > &  data,
int  val 
)

Returns first index j such that data[j] == val, or -1 if no such element

Parameters
dataa vector of integers
valthe target value
Returns
first index j such that data[j] == val, or -1 if no such element

◆ find_max()

int dsac::analysis::find_max ( const std::vector< int > &  data)

Returns the maximum value of a nonempty vector of integers

Parameters
dataa nonempty vector of integers
Returns
the largest value

◆ is_disjoint1()

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

Parameters
groupAa vector of integers
groupBa vector of integers
groupCa vector of integers
Returns
true if there does not exist a value common to all three groups

◆ is_disjoint2()

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

Parameters
groupAa vector of integers
groupBa vector of integers
groupCa vector of integers
Returns
true if there does not exist a value common to all three groups

◆ is_unique1()

bool dsac::analysis::is_unique1 ( const std::vector< int > &  data)

Returns true if there are no duplicate elements in the vector

Parameters
dataa vector of integers
Returns
true if all values are unique

◆ is_unique2()

bool dsac::analysis::is_unique2 ( const std::vector< int > &  data)

Returns true if there are no duplicate elements in the vector

Parameters
dataa vector of integers
Returns
true if all values are unique

◆ prefix_averages1()

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].

Parameters
xa vector of doubles
Returns
a vector of prefix averages

◆ prefix_averages2()

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].

Parameters
xa vector of doubles
Returns
a vector of prefix averages