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 lines below##$ rm sortrace.log # start with fresh log file#$ sortrace.sh sortrace.log & # this may take an hour##echo Generating random numberssleep generate # you have to write generate.cppsleep echo Starting system sortsleep time sort n numbers.dat systemsort.out; sortrace.log # this line is for Windows time sort n numbers.dat systemsort.out; & sortrace.log # modification for Macsleep echo Starting mysortsleep time mysort numbers.dat mysort.out; sortrace.log # this line is for Windows time mysort numbers.dat sort.out; & sortrace.log # modification for Mac computerssleep wc mysort.outsort c n mysort.out 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 o This program accepts command line arguments as shown aboveo If there are not 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 command line arguments which is the input file and the output file nameo It will accept up to 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 sizeThe bubble function takes 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 numbers. Mac users may need to make minor changes. However the graders will run your program with numbers for efficiency so make sure it works with less than 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 numbers like this:
$ head numbers.dat sort sort the first lines, send output
to stdout screen
$ tail numbers.dat sort
B sort the last 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 million random
numbers between and Write these numbers to a file
called "numbers.dat". Then run this Linux command to see how long it
takes to sort million integers:
$ time sort n numbers.dat sorted.out
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
