For this assignment, you will implement basic mergesort, binary mergesort and natural mergesort. Rather than use a menu driven program, you will use a command line driven program. In command line programs, all of the input that the program requires from the user is given on the command line. The advantage of this method is it requires no further interaction from the user, so the user can easily automate the program if they desire. Menu driven programs on the other hand are interactive and require user input throughout the execution. Refer to cli_example.cpp for an example. To run this example, try the following:
g++ -o cli_example cli_example.cpp ./cli_example ./cli_example simple file1 file2 ./cli_example binary file1 file2 ./cli_example natural file1 file2You will be writing one main program that, like cli_example, takes three command line arguments. The first argument will be "simple", "binary" or "natural" to select the mergesort algorithm to use. The second argument will be the input filename. The third argument will be the output filename. If you fail to open either file, print an error message and exit. You will also need two temporary output filenames. Use something unique like a string of random characters ("file1" or "tmp1" is not unique enough).
For the simple mergesort, split the original file evenly into the two temporary files by putting the even index elements in one file and the odd index elements in another file. (Update 10/31: Sort these two files using another sorting method such as quicksort). Then merge them using the simple merge method.
For the binary mergesort, if the size of the input file is not a power of 2 (such as 2, 4, 8, 16, etc), print an error message and exit rather than handle such sized files. Otherwise split and merge the file as stated in the text.
Likewise, for natural mergesort, split and merge the file as stated in the text.
Sample input files:
Email your completed file to me.