Answered step by step
Verified Expert Solution
Question
1 Approved Answer
THIS IS PROJECT IS LONGER SO PLEASE EMAIL ME AT XXSTUPIDMEXICAN@AOL.COM FOR THE REST OF IT , iWILL PAY IF NEEDED. The input consists of
THIS IS PROJECT IS LONGER SO PLEASE EMAIL ME AT XXSTUPIDMEXICAN@AOL.COM FOR THE REST OF IT iWILL PAY IF NEEDED.
The input consists of two parts:
The first line is the header, which is text describing the data.
The second line is the data itself, which consists of integers separated by spaces.
Test input has K integers, test input has K test input has M
For this project, given an input file of integer values, you will compute all the statistics included in a fivenumber summary or a box plot: the minimum value, the thth and th percentiles, and the maximum value.
The integers in the input will be sampled from a gamma distribution. Because of the characteristics of gamma distributions, as the input size increases, the number of unique values will grow slowly, and there will be an increasing number of duplicates, yet there is no absolute upper limit on the values. This will make the input a good candidate for a hashbased counting sort.
You will compute the fivenumber summary with each of the following methods, and benchmark the time taken for each method:
Use std::sort
Use quickselect times, then calculate the min and max separately
Modify quickselect to recurse if any of the values are in the subrange
Use a modified counting sort that uses hashes
For method find the median first. Then, on the same vector that's already partitioned around the median, call quickselect on the left half to find P and on the right half to find P Then, search the part of the vector below P for the min and above P for the max.
For method modify quickselect's recursive function to take a short list of keys rather than just one key. If you refer to p in the textbook, you can replace the parameter int k with a small vector or list. Then rewrite the recursive portion so that quickselect calls itself on one or both sides, depending on whether there are positions you're searching for on both sides or only one.
Each method should print the header from the input file, followed by lines stating the minimum, each quartile, and the maximum.
Here's an example showing the output from the sample input file:
Male elephant seal weights
Min:
P:
P:
P:
Max:
For counting sort only, also include the number of unique values. For the sample input, it would look like:
Unique:
To simplify determining which position you're looking for, Im going to keep input sizes divisible by So then, in a sorted list of elements, P is the th element, P is the th P is the th etc.
You must submit the following files:
main.cpp which reads the input from file and passes the header and data to each method.
StdSort.cpp containing the function void stdSort const std::string & header, std::vector data
StdSort.hpp containing the necessary prototypes.
QuickSelectcpp containing the function void quickSelectconst std::string & header, std::vector data
QuickSelecthpp containing the necessary prototypes.
QuickSelectcpp containing the function quickSelectconst std::string & header, std::vector data
QuickSelecthpp containing the necessary prototypes.
CountingSort.cpp containing the function void countingSort const std::string & header, std::vector data
CountingSort.hpp containing the necessary prototypes.
InsertionSort.cpp which may be blank if you wrote insertion sort directly in your QuickSelect files.
InsertionSort.hpp which may be blank if you wrote insertion sort directly in your QuickSelect files.
Yes, the functions all take the same parameters. They only take a reference to the header, which will just be printed out, and a copy of the data, which will be sorted or partitioned around several points depending on the method used.
The data is passed by value, since the function will sort the vector it's passed, and most of the methods are inplace.
You will need to write your own helper functions for each. In particular, for quickSelect, you will need to write the recursive quickSelect and use the function I require as a wrapper.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started