CIS 2168 / 2: Lab-Assignment #7: Sorting an Array Using a Heap


THIS IS A 1 WEEK ASSIGNMENT !


Simple task: use heapsort to sort an integer array. And since that task sounds dry, i'll provide a nice visualization. I created the class 'ColorBox', which, if you create an instance of it, shows up like the following image:

The ColorBox object visualizes an array of integer numbers (all values between [0,255]). As you can see, they are currently not sorted (the array of numbers is a 1 dimensional array, i'll explain in class in what order i convert it to the 2D image. It's not just row by row). You must read the values of the array, sort them (heap sort), write them back. The ColorBox will display itself like this:

Wonderful. You may use the heap sort program we talked about in class. However, you have to change it a little, since at the end of the sorting you should print the number of comparisons that were needed to build the heap and to destroy the heap (2 numbers).

Your task in steps:


Bonus points:


Here is the JAVA code for ColorBox