Login

Heapsort algorithm (Java)

School project
Finished
02 March 2008

Oblig 8:

From oblig3 you have developed and run 3 sorting algorithms; Insertion sort, Shell sort and Quick sort.
In this hand in you have to create the one more of these sorting algorithms; The Heap sort that's based on a simple priority queue.
You can use the same program that you coded in oblig3, and just continue to build on this one.

The program should be able to read a given number of people from a file, and then put this information into many person objects.
These objects are then going to be placed in a vector or array list. The person objects are so going to be sorted after last name, from A-. If a person with a similar last name occur, the first name should be used.
The person objects will so be written to a new file in the sorted order.

When you start up the program the first task that should pop up is how many persons that the user wants to read in.
The user should then be able to choose what kind of sorting algorithm he wants to use.
The user should have the possibility to do a new sorting as many times as he wants to, before he decides to exit the program.
The name of the file that's written out should be like this: PersonSortXX.dta, where XX stands for how many persons that's sorted.

In the sorting algorithms you have to count the number of comparisons that's being done, and also the number of switches. (Everything in real time) The runtime should be measured from the system clock before and after a sorting. The marginal between these two should then be your runtime.
When the sorting is done and the result is written out, the program should be able to show; total elements sorted, total comparisons, total switches and the total runtime on the screen.

Grade: B

You have to be logged in to download the project files!
If you are interested in the project files then contact me