CSCE 146

Lab 10

In this lab, you will implement file input without using the EasyReader class, and also implement some elementary operations on Heaps :

1.      The goal of this part is to read data from a text file without using the EasyReader class provided by Michael Maine. We shall view and discuss the code for doing this in lab.

2.      Write a class that implements a Heap data structure using an array. Your class should consist of  two class variables  : one for the heap array; and another for the number of elements (or size) of the heap. Implement a method  with the following signature :

private void add (int data)

{

         //method implementation

}

 

This method adds a given element to the heap using the ‘upward reheapification’ algorithm discussed in the textbook.

 

3.      Write a method with the following signature :

 

private int remove()

{

        //method implementation

}

 

        This method returns the element from the top of the heap, and then reconstructs the heap using the ‘downward reheapification’ algorithm.

 

        Enjoy!!