Below is a list of prototypes and documentation for a set of functions you are to implement. Read the documentation carefully, making sure that you implement the functions exactly as described. The list is in alphabetical order, not grouped by functionality, so read the whole list an implement them in any order that seems logical for incremental development and testing purposes.
- search for the value needle in the sorted array range given by [hay_begin ... hay_end), using the Binary Search algorithm. This function will return a pointer to the needle value if it is found, or a null pointer if needle is not found.
double* binary_search (double needle, double* hay_begin,
double* hay_end, double epsilon=1e-10);
- sort all elements in the array range [begin...end) in ascending order using the Bubble Sort algorithm
void bubble_sort (double* begin, double* end);?
-
compare two double-precision values, returning an indication of the relationship between the two such that:
result:
< 0 if v1 < v2
> 0 if v1 > v2
== 0 if v1 "==" v2 (within error bounded by epsilon)
?double epsilon_compare (double v1, double v2, double epsilon=1e-10)
void fill_array ( double* begin, double* end, double value=0.0);
- search for the value needle in the array range given by [hay_begin ... hay_end),
- using the Linear Search algorithm. This function will return a pointer to the
- needle value if it is found, or a null pointer if needle is not found.
double* linear_search (double needle, double* hay_begin,
double* hay_end, double epsilon=1e-10);
- Given a pointer to an address within an array, convert the pointer to the corresponding array index (offset). Returns the array index corresponding to ptr, or -1 if ptr was null.
int pointer_to_index (const double* ptr, const double* array_begin);
void print_array (std::ostream& stream, const double* begin, const double* end, string delim="\n");
void reverse_array (double* begin, double* end);
void selection_sort (double* begin, double* end);
****MUST CONTAIN ALL FUNCTIONS ALONG WITH COMMENTS****