public void insert(int elem){
  heap=Arrays.copyOf(heap,size + 1);
  int i=size;
  int parentIndex=(int)Math.floor((i - 1) / 2);
  while (i > 0 && elem > heap[parentIndex]) {
    heap[i]=heap[parentIndex];
    i=parentIndex;
    parentIndex=(int)Math.floor((i - 1) / 2);
  }
  heap[i]=elem;
  size++;
}

public void insert ( int elem ) { heap = Arrays . copyOf ( heap , size + 1 ) ; int i = size ; int parentIndex = ( int ) Math . floor ( ( i - 1 ) / 2 ) ; while ( i > 0 && elem > heap [ parentIndex ] ) { heap [ i ] = heap [ parentIndex ] ; i = parentIndex ; parentIndex = ( int ) Math . floor ( ( i - 1 ) / 2 ) ; } heap [ i ] = elem ; size ++ ; }
insert a new element into the heap satisfying the heap property . time complexity : o ( log n ) where ' n ' is total no . of elements in heap or o ( h ) where ' h ' is the height of heap .
