public class HeapNode{

private int size; Private int[] heap; private int[] heap; Public HeapNode(int n) {heap = new int[n]; size = 0; } public void minInsert(int key){int I = this.size; if (i==0) heap[0] = key; else { while (i>0 && heap[i/2]>key){ heap[i] = heap[i/2]; i = i/2; } heap[i] = key; } this.size++; } public void maxInsert(int key){int I = this.size; if (i==0) heap[0] = key; else { while (i>0 && heap[i/2]<key){ heap[i] = heap[i/2]; i = i/2; } heap[i] = key; } this.size++; } public int minDelete(){if (this.size==0) return -1; int top = heap[0]; int last = heap[this.size-1]; heap[0] = last; this.size--; / / / metal futures (https://www.gendan5.com/cf/mf.html) heap minHeapify (0); return top; } public int maxDelete(){if (this.size==0) return -1; int top = heap[0]; int last = heap[this.size-1]; heap[0] = last; this.size--; / / heap maxHeapify (0); return top; } public void minHeapify(int I){int L =2* I,R=2* I +1,min; if (L<=size && heap[L] < heap[i]) min = L; else min = i; if (R <= size && heap[R] < heap[min]) min = R; if (min! =i){ int t = heap[min]; heap[min] = heap[i]; heap[i] = t; minHeapify(min); }} public void maxHeapify(int I){int L =2* I,R=2* I +1, Max; if (L<=size && heap[L] > heap[i]) max = L; else max = i; if (R <= size && heap[R] > heap[max]) max = R; if (max! =i){ int t = heap[max]; heap[max] = heap[i]; heap[i] = t; maxHeapify(max); } public void print(){for (int I = 0; i < this.size; i++) { System.out.print(heap[i]+" "); } System.out.println(); }

}