Question: Data Text File: Problem Write a C++ program that (i) reads numbers from a file data.txt; (ii) uses the quickselect algorithm' to compute the 25-th

Data Text File:

Problem Write a C++ program that (i) reads numbers from a file data.txt; (ii) uses the quickselect algorithm' to compute the 25-th percentile, the 50-th percentile, and the 75-th percentile of these numbers; and (iii) outputs the computed percentiles to the terminal. For the output, simply output all three numbers in a single line separated by spaces. Do not output anything else; do not ask the user for input. Input File. The numbers in the file data.txt are all non-negative integers. The first number of the file, say n, states how many numbers follow. The next n lines all contain a single number. Compute the percentiles of these n numbers (not including n itself). Wirte your program in such a way that the file can contain more than n +1 lines and still works correctly (i. e., computes the percentile of the n given numbers). Percentile. The p-th percentile of a set S is the smallest element e in S such that at least p% of the elements in S (including e) are smaller than or equal to e. To compute the p-th percentile, implement a function int percentile(int p, int S[], int size) which takes a percentage-value p and a (potentially unsorted) array S as input and returns the corresponding percentile. Your implementation must work for any p with 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
