Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function named selection _ sort ( ) which takes two parameters, a integer pointer and an integer size. Add code to implement a

Write a function named selection_sort() which takes two parameters, a integer pointer and an integer size. Add code to implement a selection sort algorithm. Add any needed functions to support the selection sort.
Write a helper function named binary_search that takes three parameters, the first is an integer array, the second is the searched for value, and the third is the array size. This function calls the recursive function and passes the array, the search value, the starting index, and the last index.
Write a recursive function named binary_search_recursive() which takes four parameters passed from the helper function. The first is an integer pointer representing the array of values, the second is an integer representing the value to be searched for, the third is an integer for the starting index, and the fourth is an integer for the ending index.
Add a new class named SearchAnalyzer which subclasses Analyzer and implements the analyze() method. Use the override keyword appropriately. The constructor should first call the selection_sort() function, passing the integer array and the size. In the analyze() method, generate 100 random integer values in the range of 0 to 999 and use the binary_search() function to see if that value exists in the data. Count the number of found values and return the count in a std::string.
Modify the StatisticsAnalyzer analyze() method to call the selection_sort() function. Alter the computation of the minimum and maximum values considering that the array is sorted. Add functionality to implement the median and mode averages using the sorted data. The median is the exact middle value (if there are an odd number of elements) and the mean of the two middle values (if there are an even number of elements). The mode is the most frequently occurring value; if more than one value occurs with this frequency, pick the first one.
Write a CPP code implementing each of these
bool binary_search_recursive(int* values, int key, int start,
int end)
bool binary_search(int* values, int key, int size) void createBinaryFile(std: string filename) void selection_sort (int* values, int size)
void writeBinary (std: :string filename, int* values, int length)
class BinaryReader
BinaryReader (std:: string filename)
~BinaryReader ()
int* getValues ()
int getSize)
void readValues (std:: string)
class Analyzer
Analyzer (int* values, int size)
~Analyzer )
int* cloneValues (int*, int)
virtual std: :string analyze)=0
class DuplicatesAnalyser : public Analyzer
DuplicatesAnalyser(int* values, int size)
std: :string analyze() override
class MissingAnalyser
MissingAnalyser (int* values, int size)
std:: string analyze) override
class SearchAnalyzer : public Analyzer
SearchAnalyzer (int* values, int size)
std:: string analyze() override
class StatisticsAnalyser
StatisticsAnalyser (int* values, int size)
std:: string analyze) override
the output should look like this
The minimum value is 0
The maximum value is 999
The mean value is 499.495000
The median value is 497
The mode value is 81 which occurred 5 times
There were 269 duplicated values
There were 361 missing values
There were 67 out of 100 random values found

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions