Data Structures
Project 5: Sorting Algorithm Comparison
Due: April 29, Wednesday, by 11:59 PM
Description
You will write a program to compare 5 sorting algorithms: selection sort, insertion sort, heapsort,
merge sort, and quicksort. The program will be sorting words/strings by lexicographic order.
For each algorithm, the program will count the number of comparisons taken, and record time
spent in milliseconds for each sorting algorithm. Only direct comparisons among words need to be
counted. In addition, you need to Google to find out how to record time spent in Java.
Input
Standard input will be used. The program needs to accept keyboard input. However, you could
use < to redirect keyboard input to a text file, like what you did in Project 1. A text file containing
lots of words is provided on TCU Online. Just select part of the word list to test your program.
The input format of this program is that the first line will be an integer indicating the number
of words to be sorted. Then, beginning from the second line, words are listed, and each line only
contains one word.
Output
Standard output will be used. Here is an example of the output. (The results are fictitious.)
ALGORITHM | | Comparisons | Time (Milliseconds) | |
================+=============+===================== | ||
Selection Sort | 123456789 | | 1234.56789 | |
—————-+————-+——————— | ||
Insertion Sort | 123456789 | | 1234.56789 | |
—————-+————-+——————— | ||
Heapsort | | 123456789 | | 1234.56789 |
—————-+————-+——————— | ||
Merge Sort | | 123456789 | | 1234.56789 |
—————-+————-+——————— | ||
Quicksort | | 123456789 | | 1234.56789 |
—————-+————-+———————
Your output must be similar to the above example, but not necessarily be exactly the same.
1
Implementation
For this project, the design is flexible, but must meet the following requirements.
• You program should contain a Project5.java file, which is the entrance of the program.
• Besides Project5.java, there should be at least 5 more Java files. Each file is designated for
one of the 5 sorting algorithms.
• Your submission must contain a Readme.txt file to have a description of each Java file in
your program.
You can directly use any code from the textbook. In addition, you can use the same data
structure of your choice to implement all 5 sorting algorithms, or use different data structures for
different sorting algorithms. Moreover, besides the 6 Java files mentioned above, you can have
additional Java files to facilitate the implementation. These additional files must also be described
in the Readme.txt file.
Assessment, Submission, and Grading
1. This is an individual project.
2. Your program must be written in Java.
3. Your program will be tested using standard input and output in a terminal environment.
4. You must use good software design.
5. Have sufficient comments in your code that could facilitate others to understand
your code.
6. A readme.txt file must be included.
7. Submit a .zip file to TCU Online by the assigned date.
8. This project is worth 100 points.
2
The post Sorting Algorithm Comparison appeared first on My Assignment Online.