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

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 numbers
sleep 1
generate 1000000-100000100000 # you have to write generate.cpp
sleep 1
echo Starting system sort
sleep 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 Mac
sleep 1
echo Starting mysort
sleep 1
{ time(.)/(m)ysort numbers.dat mysort.out; }2>> sortrace.log # this line is for Windows
{ time(.)/(m)ysort numbers.dat sort.out; }2>&1>> sortrace.log # modification for Mac computers
sleep 1
wc mysort.out
sort -c -n mysort.out 2>> sortrace.log # verify file is sorted
You must write the following programs
* generate.cpp
o Purpose: generate a file called numbers.dat
o Description: The numbers.dat file will have COUNT random numbers between MIN and MAX
o Usage: generate COUNT MIN MAX
o Example: generate 1000000-100000100000
o This program accepts 3 command line arguments as shown above
o If there are not 3 command line arguments, the program fails and prints error message
* mysort.cpp
o Purpose: read numbers from input file, sort, write sorted numbers to output file
o Description: Uses bubble sort function on an array of integers
o Usage: mysort numbers.dat mysort.out
o It accepts 2 command line arguments which is the input file and the output file name
o 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.cpp
You 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 function
generate 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.
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!