3 ms·
Using an array as a heap is also easier with 1-based indexing: base-element := some-vector[i]; left-child := some-vector[i * 2]; right-child := some-vect
by tmtvl 2y ago
Using an array as a heap is also easier with 1-based indexing:
base-element := some-vector[i];
left-child := some-vector[i * 2];
right-child := some-vector[i * 2 + 1];
where the root element is `some-vector[1]'.