The main objective of this assignment is to demonstrate your understanding file input and output, and to implement an algorithm to merge two unsorted data files into one sorted data file.
Considerations:
Use the start-up source code file MergeSort.cpp provided to complete this assignment. Start by creating a new empty project and the copy the source code (.cpp) file and data .txt files into the project folder. Then right-click the Source node in Solution Explorer to Add Existing item into your projects solution. Be sure you can compile, load and run the program to make sure that much works, which should print some messages to the screen and create an output file that initially will be empty you will be merging two sorted lists into one sorted output file. Complete the TODO comments where indicated in the source code file.
Given input files A and B read into two arrays and then sorted separately, the program will use those two lists and the algorithm that follows to write the merged output file AB (Note: TestScoresMergeAB file should contain just one
TestScoresA
88
87
88
66
55
56
75
75
78
80
80
90
99
87
44
34
0
100 TestScoresB
80
91
55
67
75
90
80
100
35
98
0
66
99
87
75
34
15
90
88
100
44
83 TestScoresMergeAB
0
0
15
34
34
35
44
44
55
55
56
66
66
67
75
75
75
75
78
80
.
. TestScoresMergeAB
.
.
80
80
80
83
87
87
87
88
88
88
90
90
90
91
98
99
99
100
100
100
This will not be an interactive program, but console output should include at least the following messages about program activity:
Opening files....
Reading files....
Merging files....
Finishing up....
End program.
Use the algorithm shown here to implement your solution.
Merge list-A and list-B into output file-AB
until (end-of-list-A) or (end-of-list-B)
if next-A <= next-B then
write next-A to file-AB
increment list-A counter
else
write next-B to file-AB
increment list-B counter
if (end-of-list-A) then
until (end-of-list-B)
write next-B to file-AB
increment list-B counter
else
until (end-of-list-A)
write next-A to file-AB
increment list-A counter
close output file-AB