Question: I. Inputs: - 1 for hard copy file name. a ) inFile ( argv [ 1 ] ) : a file contains a list of
I. Inputs: for hard copy file name.
a inFile argv : a file contains a list of integers, not in particular format.
declare inFile as ifstream data type.
II Output: for hard copy file name.
a outFile argv : a file contains a list of sorted integers from the input data in ascending order.
declare inFile as ofstream data type.
b deBugFile argv : 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 A 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 textline; fileOut can be outFile or deBugFile.
See algorithm steps below.
IV main
step : inFile open input file via argv ie ifstream inFile.open argv
outFile open output file via argv ie ofstream outFile.open argv
deBugFile open deBugFile via argv ie ofstream deBugFile.open argv
step : count countData inFile deBugFile
deBugFile In main count write count.
ie deBugFile In main count count
step : dataAry dynamically allocate, size of count. ie dataAry new int count
step : close inFile
step : inFile open input file via argv reopen inFile
step : loadData inFile dataAry, count, deBugFile
step : outFile printing data of before sorting.
printDataAry dataAry count, outFile, deBugFile
step : selectionSort dataAry count, deBugFile
step : outFile Printing data after sorting.
printDataAry dataAry count, outFile, deBugFile
step : close all files
Vint countData inFile deBugFile
step : deBugFile Entering countData
step : count
step : data read an integer at a time from inFile ie inFile data
step : count
step : repeat step to step while inFile is NOT empty.
step : deBugFile leaving countData count write count
step : return count
VI loadData inFile dataAry, count, deBugFile
step : deBugFile Entering loadData
step : index
step : data read an integer at a time from inFile ie inFile data
step : dataAry index data
step : index
step : repeat step to step while inFile NOT empty and index count
step : deBugFile leaving loadData
VII. selectionSort dataAry count, deBugFile
step : deBugFile Entering selectionSort
step : i
step : minVal dataAryi
minIndex i
j i
step : if dataAryj minVal
minIndex j
minVal dataAryj
step : j
step : repeat step to step while j count
step : if minIndex i
tmp dataAry i
dataAry i dataAry minIndex
dataAry minIndex tmp
step : deBugFile In selectionSort printing dataAry i minIndex write i and minIndex
printDataAry dataAry count, deBugFile
step : i
step : repeat step to step while i count
step : deBugFile leaving selectionSort
VIII. printDataAry dataAry count, fileOut, deBugFile
step : deBugFile Entering printDataAry
step : index
step : fileOut dataAryindex ie fileOut dataAryindex
step : index
step : repeat step to step while index count
step : deBugFile leaving printDataAry
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
