Question: HOMEWORK - SORT AND MERGE Write a program that performs the following tasks: Display a friendly greeting to the user Prompt the user for a
HOMEWORK SORT AND MERGE
Write a program that performs the following tasks:
Display a friendly greeting to the user
Prompt the user for a file name a list of numbers to be sorted
Accept that file name
Prompt the user for a second file name another list of numbers to be sorted
Accept that file name
Open and read the data in the first file
Sort that data using an algorithm that you wrote yourself not Array.sort
o The lists will be sufficiently large that a simple algorithm wont suffice
Open and read the data in the second file
Sort that data, again using your own algorithm
Merge the two sorted arrays into a single sorted array see Problem using a linear
algorithm that makes only one pass through the arrays.
Prompt the user for a file name
Create that file and dump the merged list to the file, using the format specified
The program should check the command line for the parameters.
If three commandline parameters are given, accept them; otherwise, prompt for all three.
The file format is as follows: a single integer, followed by that number of integers.
That way you can open the file, read the first value, create an array of the appropriate size, and
then read the rest of the file to populate the array. For example
is data in the specified format. The first is the count, not a data item.
Note that there can be more data items than indicated by the count; ignore the extras.
This assignment began, back in the day, as just the merge problem from the textbook.
It has evolved into natural merge sort, with the last merge as a separate step.
The natural merge algorithm will satisfy the merge portion of this assignment.
It is highly recommended that you write the full natural merge sort for the sorting algorithm.
The split and merge algorithms are tested on Moodle, so you will have both pieces.
DELIVERABLES:
Your Java source code.
A screen shot of your program in action, using input files of your own making, but each with a
size of at least integers. Make sure your displayArray function handles large files
correctly first last entries only DO NOT SUBMIT THE ACTUAL DATA FILES.
Text files with half a million integers will cause the Moodle previewer to die a horrible death.
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
