Question: Please don't copy the code whihch alreday exists C++ (below is a file i alredy create to generate number) by using that create new cpp

Please don't copy the code whihch alreday exists

C++ (below is a file i alredy create to generate number)

by using that create new cpp file and write a sort function that is O(n-squared) in C++

Acept 2 comd line arguments input file and output file name.

Reads in the integers from the input file into an array.

Sorts the array using O(n-squared) sorting algorithm.

Writes the sorted array to the output file.

mycode

#include #include #include

using namespace std;

int main(int argc, char* argv[]) { if (argc != 4) { cerr << "Usage: generate COUNT MIN MAX" << endl; return 1; }

int count = atoi(argv[1]); int min = atoi(argv[2]); int max = atoi(argv[3]);

ofstream cout("numbers.dat");

for (int i = 0; i < count; i++) { int num = (rand() % (max - min + 1)) + min; cout << num << endl; }

cout.close();

return 0; }

Finally Test with below

############################################################ # this file should be called sortrace.sh Please rename it # it must have execute privilege set to run # run it as a background task like this: # $ rm sortrace.log # start with fresh log file # $ sortrace.sh >> sortrace.log & ########################################################### echo Generating 1000000 random numbers sleep 1 generate 1000000 100000 999999 # you have to write generate.cpp sleep 1 echo Starting system sort sleep 1 { time sort numbers.dat > systemsort.out; } 2>> sortrace.log sleep 1 echo Starting my sort sleep 1 { time mysort numbers.dat mysort.out; } 2>> sortrace.log # you have to write mysort.cpp sleep 1 sort -c mysort.out 2>> sortrace.log # verify file is sorted

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!