Finally, if the array of the top element has more elements, we’ll insert the next element to the heap.
More elements than?
What is top element here?
There is just this condition
if (list.length > i + 1) {
There is no condition in code to correspond to above statement.
Can anyone help me?