Question: using the code below in C++, Pass each of the array to the sorting as a parameter functions one by one and calculate the running
using the code below in C++, Pass each of the array to the sorting as a parameter functions one by one and calculate the running time of each function for each array using "chrono" library of C++. make a 2D array of size 6*10 of type "float" and store each of the result i.e., the execution time of each function.
#include#include using namespace std; int main() { // string array to store the file names string filenames[] = {"dataset0.txt","dataset1.txt","dataset2.txt","dataset3.txt","dataset4.txt","dataset5.txt", "dataset6.txt","dataset7.txt","dataset8.txt","dataset9.txt"}; // 2D array to store the integers // arr[i][0] -> stores current row size i.e, number of integers, it has stores from file 'i' int arr[10][10000]; // For loop the read all the integers from each of the files for(int i=0;i<10;i++) { ifstream is(filenames[i]); // opening the file 'i' to read the integers int count= 1; // initializing the count with 1, as 0th position stores the size of the current row int x; // integer variable to read integers from the file // reading each and every integer from the current file while (is >> x) // until we are geeting the integers in the file, we will keep on reading arr[i][count++] = x; // storing the current integer read from the file into the array arr[i][0] = count; // storing the size of the current row into the first column //close the file is.close(); } // Printing the contenets of the array for(int i=0;i<10;i++) { cout << filenames[i].substr(0, 8) << ": "; for(int j=1;j
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
