public void insert(E element) {
        heap.insert(element);
        int i = heapSize;
        while (i > 0 && heap.get(parent(i)).compareTo(element) > 0) {
            swapElementsByIndex(i, parent(i));
            i = parent(i);
        }
        heap.set(i, element);
        heapSize++;
    }