public void maxheapify(int[] a,int index,int heapSize){
        
        int leftIndex = 2*index;
        int rightIndex = 2*index+1;
        int largest = index;
        if (leftIndex<=heapSize && a[leftIndex-1]>a[index-1])
        {
            largest=leftIndex;
        }
        if (rightIndex<heapSize && a[rightIndex-1]>a[largest-1])
        {
            largest=rightIndex;
        }
        
        if (largest!=index)
        {
            int temp = a[index-1];
            a[index-1]=a[largest-1];
            a[largest-1]=temp;
            maxheapify(a, largest,heapSize);
        }
    }