Question: I. Inputs: - 1 for hard copy file name. a ) inFile ( argv [ 1 ] ) : a file contains a list of

I. Inputs: -1 for hard copy file name.
a) inFile (argv [1]): a file contains a list of integers, not in particular format.
// declare inFile as ifstream data type. *************************************
II. Output: -1 for hard copy file name.
a) outFile (argv [2]): a file contains a list of sorted integers (from the input data) in ascending order.
// declare inFile as ofstream data type.
b) deBugFile (argv [3]: contain all the debugging dictate by the program.
// declare inFile as ofstream data type.
*************************************
III. Data structures:
- A sort class:
int count;
int* dataAry; // a dynamically allocate array to store the input data, to be sorted.
method:
- constructor (...)
-(int) countData (...)// read and return the count of data in the inFile, as in your project 0A. See
//algorithm steps below
- loadData (...)// read data from inFile and store the data in dataAry. See algorithm steps below.
- selectionSort (...)// See algorithm steps below.
- printDataAry (dataAry, count, fileOut, deBugFile)
// Print dataAry to fileOut, one data per text-line; fileOut can be outFile or deBugFile.
//See algorithm steps below.
*************************************
IV. main (...)
*************************************
step 0: inFile open input file via argv [1]// i.e., ifstream inFile.open (argv [1])
outFile open output file via argv [2]// i.e., ofstream outFile.open (argv [2])
deBugFile open deBugFile via argv [3]// i.e., ofstream deBugFile.open (argv [3])
step 1: count countData (inFile, deBugFile)
deBugFile In main () count = write count.
// i.e., deBugFile <<In main () count=<< count <<
step 2: dataAry dynamically allocate, size of count. // i.e., dataAry = new int [count]
step 3: close inFile
step 4: inFile open input file via argv [1]// re-open inFile
step 5: loadData (inFile, dataAry, count, deBugFile)
step 6: outFile ** printing data of before sorting. **
printDataAry (dataAry, count, outFile, deBugFile)
step 7: selectionSort (dataAry, count, deBugFile)
step 8: outFile ** Printing data after sorting. ***
printDataAry (dataAry, count, outFile, deBugFile)
step 9: close all files
*************************************
V.(int) countData (inFile, deBugFile)
*************************************
step 0: deBugFile Entering countData ()
step 1: count 0
step 2: data read an integer at a time from inFile // i.e., inFile >> data
step 3: count++
step 4: repeat step 2 to step 3 while inFile is NOT empty.
step 5: deBugFile leaving countData count = write count
step 6: return count
*************************************
VI. loadData (inFile, dataAry, count, deBugFile)
*************************************
step 0: deBugFile Entering loadData ()
step 1: index 0
step 2: data read an integer at a time from inFile // i.e., inFile >> data
step 3: dataAry [index] data
step 4: index++
step 5: repeat step 2 to step 4 while inFile NOT empty *and* index < count
step 6: deBugFile leaving loadData
*************************************
VII. selectionSort (dataAry, count, deBugFile)
*************************************
step 0: deBugFile Entering selectionSort ()
step 1: i 0
step 2: minVal dataAry[i]
minIndex i
j i+1
step 3: if dataAry[j]< minVal
minIndex j
minVal dataAry[j]
step 4: j++
step 5: repeat step 3 to step 4 while j < count
step 6: if minIndex != i
tmp dataAry [i]
dataAry [i] dataAry [minIndex]
dataAry [minIndex] tmp
step 7: deBugFile ** In selectionSort printing dataAry i = minIndex=// write i and minIndex
printDataAry (dataAry, count, deBugFile)
step 9: i++
step 10: repeat step 2 to step 9 while i < count -1
step 11: deBugFile leaving selectionSort ()
*************************************
VIII. printDataAry (dataAry, count, fileOut, deBugFile)
*************************************
step 0: deBugFile Entering printDataAry ()
step 1: index 0
step 2: fileOut dataAry[index]// i.e., fileOut << dataAry[index]<<
step 3: index++
step 4: repeat step 2 to step 3 while index < count
step 5: deBugFile leaving printDataAry ()

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!