Question: Your job is to write a sort program that uses the bubble sort. This will take some time to sort and we dont want to

Your job is to write a sort program that uses the bubble sort. This will take some time to sort and we dont want to wait around for the results, so we will run the program in the background using the &. You will run this shell file to test your program: # This file is called sortrace.sh# It must have execute privilege set to run# run it as a background task like this: (see the 2 lines below)#----------------------------------------------------------------------------------------------#$ rm sortrace.log # start with fresh log file#$ sortrace.sh >> sortrace.log & # this may take an hour#----------------------------------------------------------------------------------------------#echo Generating 1000000 random numberssleep 1generate 1000000-100000100000 # you have to write generate.cppsleep 1echo Starting system sortsleep 1{ time sort -n numbers.dat > systemsort.out; }2>> sortrace.log # this line is for Windows{ time sort -n numbers.dat > systemsort.out; }2>&1>> sortrace.log # modification for Macsleep 1echo Starting mysortsleep 1{ time ./mysort numbers.dat mysort.out; }2>> sortrace.log # this line is for Windows{ time ./mysort numbers.dat sort.out; }2>&1>> sortrace.log # modification for Mac computerssleep 1wc mysort.outsort -c -n mysort.out 2>> sortrace.log # verify file is sorted You must write the following programs generate.cppo Purpose: generate a file called numbers.dato Description: The numbers.dat file will have COUNT random numbers between MIN and MAXo Usage: generate COUNT MIN MAXo Example: generate 1000000-100000100000o This program accepts 3 command line arguments as shown aboveo If there are not 3 command line arguments, the program fails and prints error message mysort.cppo Purpose: read numbers from input file, sort, write sorted numbers to output fileo Description: Uses bubble sort function on an array of integerso Usage: mysort numbers.dat mysort.outo It accepts 2 command line arguments which is the input file and the output file nameo It will accept up to 1 million numbers from the input file, but will run successfully with less Requirements:Use an array to store your numbers in mysort.cppYou must have a function called bubble( int A[], int size)The bubble function takes 2 parameters the array and the number of items to sort.The bubble function will be called from the main functiongenerate and mysort programs must work according to the above descriptions What to submit: mysort.cpp generate.cpp sortrace.log sortrace.sh Notice Your requirement is to use the exact sortrace.sh file listed above which sorts 1,000,000 numbers. Mac users may need to make minor changes. However the graders will run your program with 10,000 numbers for efficiency so make sure it works with less than 1,000,000 numbers as described in the requirements.
Linux has a sort command. If you wanted to use the Linux sort command
to sort all the items in a file called "numbers.dat", you could use it like
this:
$ sort numbers.dat
the file like text
$ sort -n numbers.dat
the file like numbers
$ sort -c numbers.dat
BThis command treats the contents of
B this command treats the contents of
B this checks to see if the file is sorted
You could also sort the file like this:
$ cat numbers.dat | sort Bsend output to stdout using cat, then
pipe that to the sort command
$ more numbers.dat | sort
Bsend output to stdout using more,
then pipe that to the sort command
You could sort the first or last 1000 numbers like this:
$ head -1000 numbers.dat | sort B sort the first 1000 lines, send output
to stdout (screen)
$ tail -1000 numbers.dat | sort
B sort the last 1000 lines, send
output to stdout (screen)
Each of the above commands will display the sorted numbers (lines) on
the screen. Instead of displaying the numbers, you could write them to a
file called "sorted.out"
Internal
$ cat numbers.dat | sort > sorted.out
called "sorted.out"
$ sort -n numbers.dat > sorted.out
In this assignment you will generate a file that has 1 million random
numbers between -100000 and +100000. Write these numbers to a file
called "numbers.dat". Then run this Linux command to see how long it
takes to sort 1 million integers:
$ time sort -n numbers.dat > sorted.out
Your job is to write a sort program that uses the

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 Programming Questions!