I am trying to implement the MAX-HEAP-INSERT(A,key) function. It's pseudocode is:
MAX-HEAP-INSERT(A,key) 1 A.heap-size = A.heap-size+1 2 A[A.heap-size] = -inf 3 HEAP-INCREASE-KEY(A,A.heap-size,key) Where HEAP-INCREASE-KEY(A,A.heap-size,key) is another function which i didn't have trouble understanding.
The heap is based on an array A, and as we know arrays are limited. So, when we increase the A.heap-size won't there be a problem when A.heap-size gets bigger than A.length?