Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

Determine miller indices of plane A Z a/2 X a/2 a/2 Y

Answered: 1 week ago