private void bubbleDown() {
        int index = 1;
        
        if (comp==null){
        while (hasLeftChild(index)) {
            int smallerChild = index*2;

            if (hasRightChild(index)
                && ((Comparable) data[index*2]).compareTo(data[(index*2+1)]) > 0) {
                smallerChild = (index*2+1);
            } 
            
            if (((Comparable) data[index]).compareTo(data[smallerChild]) > 0) {
                swap(index, smallerChild);
            } else {
                break;
            }
            index = smallerChild;
        }
        }
        else{
            while (hasLeftChild(index)) {

                int smallerChild = index*2;

                if (hasRightChild(index)
                    && comp.compare(data[index*2], data[(index*2+1)]) > 0) {
                    smallerChild = (index*2+1);
                } 
                
                if (comp.compare(data[index], data[smallerChild]) > 0) {
                    swap(index, smallerChild);
                } else {

                    break;
                }
                

                index = smallerChild;
            }
        }
    }