2

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?

0

1 Answer 1

1

Yes. If this happens you have to increase the size of your array.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.