This program is used from the console. In Windows, open a command prompt and "cd" to the directory that contains hw5.exe. In Linux, open a terminal and "cd" to the directory that contains the file hw5.
You can see the way commands should be specified by running the program with no arguments. So type "hw5" (Windows) or "./hw5" (Linux) and press Enter. The program will display some examples of commands.
You can see a demonstration of an algorithm by typing "hw5 demonstrate" and pressing Enter. The program will print some unsorted predefined arrays and use a preselected algorithm to sort the arrays and print them again.
To test a sorting algorithms speed for comparison against other algorithms, we need some data. This program has the ability to generate that data. To generate this data, type:
"hw5 10000 randnums.txt increasing.txt decreasing.txt"
This command generates 10000 random numbers, writes them to the file randnums.txt, then sorts the numbers into increasing order and writes them to increasing.txt, and finally reverses the numbers and writes them to decreasing.txt. (This usually doesn't take more than a couple seconds) You can substitute any number for 10000. This number is how many random numbers will be generated, i.e. the number of items to sort. This number needs to be fairly large as the algorithms are capable of sorting data very quickly. Numbers that are too small will take such a short amount of time, you won't be able to see a difference among the algorithms. To big of a number can cause the algorithms to take several minutes to finish. The 3 .txt files can be named anything you want, they are the files where the data will be written to.
Now that you have some random numbers, you can test a sorting algorithm on the data. For example, to run Merge Sort on the 10000 random numbers, type the command:
"hw5 merge 3 randnums.txt"
This uses Merge Sort 3 times on the data. You can substitute any number in for 3. When the sorting is done, the program will report the amount of time taken. Try substituting increasing.txt or decreasing.txt in for randnums.txt in the command and see what happens with the algorithms.
Thanks for trying the program. Let me know what you think/suggestions/bugs/help/etc on the Message Board.
This program has been downloaded
180 times since July 9, 2004.
Page created 7-9-04
Page last updated 11-12-04.