Answered step by step
Verified Expert Solution
Link Copied!

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 1 has 1K integers, test input 2 has 100K, test input 3 has 10M.
For this project, given an input file of integer values, you will compute all the statistics included in a five-number summary or a box plot: the minimum value, the 25th,50th, and 75th 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 hash-based counting sort.
You will compute the five-number summary with each of the following methods, and benchmark the time taken for each method:
1) Use std::sort
2) Use quickselect 3 times, then calculate the min and max separately
3) Modify quickselect to recurse if any of the 5 values are in the subrange
4) Use a modified counting sort that uses hashes
For method 2, find the median first. Then, on the same vector that's already partitioned around the median, call quickselect on the left half to find P25 and on the right half to find P75. Then, search the part of the vector below P25 for the min and above P75 for the max.
For method 3, modify quickselect's recursive function to take a short list of keys rather than just one key. If you refer to p.322 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 5 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: 5069
P25: 5796
P50: 6129
P75: 6548
Max: 9218
For counting sort only, also include the number of unique values. For the sample input, it would look like:
Unique: 787
To simplify determining which position you're looking for, I'm going to keep input sizes divisible by 100. So then, in a sorted list of 1000 elements, P25 is the 250th element, P50 is the 500th, P75 is the 750th, 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.
QuickSelect1.cpp, containing the function void quickSelect1(const std::string & header, std::vector data)
QuickSelect1.hpp, containing the necessary prototypes.
QuickSelect2.cpp, containing the function quickSelect2(const std::string & header, std::vector data)
QuickSelect2.hpp, 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 in-place.
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

an element of formality in the workplace between different levels;

Answered: 1 week ago