Binary Heap - Max Heap - All Operations Implementation
public class Main { // the array used to implement max heap // left child index is [2*x] and right child index is [(2*x)+1] if 'x' is the index of parent in array 'arr'. // Cell 0 is unused for the sake of mathemaical simplicity. int arr[]; // variable to store the last used index of arr int lastUsedIndex; // creating heap using constuctor // Time Complexity - O(1) , Space Complexity - O(n) Main(int size){ this.arr = new int[size]; this.lastUsedIndex=0; } // method to initialize the arr with Integer.MIN_VALUE, when it is empty public void initializeArray(){ if(this.lastUsedIndex==0){ for(int i=0;i<this.arr.length;i++){ ...