Question: Lab Exercise: 1. Class Node that includes the following instance variables: int data; String name; Your class should have the following: A constructor that initializes
Lab Exercise: 1. Class Node that includes the following instance variables: int data; String name; Your class should have the following: A constructor that initializes the instance variables. Setter and getter methods for the instance variables. .toString method that returns a String including (id : name) 2. Class MaxHeap that includes the instance variables: NodellheapArray; int maxSire; // size of array int currentSize; // number of Nodes in heapArray Your class should have the following: constructor that takes the maximum size allowed for the heap. The current size of the heap is set to 0, and the array of the heap is created with size = maxSize public boolean insert (int key, String Name) inserts a value at the end of the heap then calls method reheapUp to apply the actual changes to the heap. private void reheapUp (int index) applies the actual changes to the heap after insertion Makes sure that a child node is always less than its parent. It starts at the end of the heap and moves up. public Node remove removes the first (root) value from the heap. It calls method reheap Down to apply the actual changes to the heap for removal. private void reheapDown(int index) applies the actual changes to the heap after remove. Makes sure that a parent node is always greater than its children. It starts at the end of the root of the heap and moves down. public boolean isEmpty O checks whether the heap is empty or not public void printHeap 0 prints the contents of the heap as shown in the sample output. 3. Write a test application named TestLabs. In the main method, do the following
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
