Question: IN JAVA PLEASE ! ! Need help implementing public add ( T newEntry ) and public T removeMin ( ) import java.util.Arrays; public class MinHeap

IN JAVA PLEASE !!
Need help implementing
public add(T newEntry) and
public T removeMin()
import java.util.Arrays;
public class MinHeap>{
private T[] heap;
private int lastIndex;
private boolean integrityOK = false;
private static final int DEFAULT_CAPACITY =5;
private static final int MAX_CAPACITY =1000;
public MinHeap(){
this(DEFAULT_CAPACITY);
}
public MinHeap(int initialCapacity){
if(initialCapacity < DEFAULT_CAPACITY){
initialCapacity = DEFAULT_CAPACITY;
}
else if(initialCapacity > MAX_CAPACITY){
throw new IllegalStateException("array too large");
}
T[] tempHeap =(T[]) new Comparable[initialCapacity+1];
heap = tempHeap;
lastIndex =0;
integrityOK = true;
}
private void checkIntegrity(){
if(integrityOK==false){
throw new SecurityException("array was not made right!");
}
}
public void add(T newEntry){
//TODO
}
public T removeMin(){
checkIntegrity();
//TODO
return null; // Return the maximum value
}
public boolean isEmpty(){
return lastIndex<1;
}
public int getSize(){
return lastIndex;
}
public void clear(){
checkIntegrity();
while(lastIndex >-1){
heap[lastIndex]= null;
lastIndex--;
}
lastIndex =0;
}
public void print_array(){
System.out.println(Arrays.toString(heap));
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!