
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Algorithms and Data Structures; Subject: Computer Science; University: University of Alabama - Birmingham; Term: Spring 2008;
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

February 7, 2008
A Binary min-heap can be seen as a binary tree with two additional constraints: (1) the shape property, and (2) heap property.
(1) The shape property: all levels of the tree, except possibly the last one (deepest) are fully filled, and if the bottom level of the tree is not complete, the nodes of that level are filled from left to right. (2) The heap property: each node is less than or equal to each of its child nodes according to some comparison predicate which is fixed for the entire data structure. In this assignment, you will use the heap property of the binary min-heap to for sorting a dataset in descending order.
There are two templates in the source code provided, including: Heap.java and HeapSort.java
The first class is Heap.java which enables you to build and manipulate a binary min-heap tree. The Heap class contains an inner class โNodeโ which is identical to the one provided in our previous exercise and programming assignment.
(1) The constructor of Heap() allows you to build a binary min-heap tree for the given dataset. To build the binary min-heap tree. You will need to implement the insert() method. This method allows you to insert an element to the binary min-heap tree in ๐ log ๐. Hence, you can successively insert your data to build the tree in ๐ ๐ log ๐. (2) Once the binary min-heap tree is built, you are going to generate the sorting result. All you need to do is to implement the delete() in the Heap class. The delete () method allows you to remove the root node from the binary min-heap structure, and return the value of the removed root.
The second one is HeapSort.java. You should use the binary min-heap structure for sorting the dataset provided.
(1) Create the binary min-heap tree. (2) Return the sorting result.
Two-page report is required.
( Bonus ) Figure out an optimal method to build the binary min-heap tree in ๐ ๐.