public void insert(int value) throws Exception {
        if (this.lastFreePos == this.values.length) {
            throw new Exception("Heap overflow");
        }
        this.values[this.lastFreePos] = value;
        int childPos = this.lastFreePos, parentPos = (childPos - 1) / 2, aux;
        while (parentPos >= 0 && this.values[parentPos] > this.values[childPos]) {
            aux = this.values[parentPos];
            this.values[parentPos] = this.values[childPos];
            this.values[childPos] = aux;
            childPos = parentPos;
            parentPos = (childPos - 1) / 2;
        }
        this.lastFreePos++;
    }