3 ms·
That's arguably one of the only downsides of zero-based, and can be handled easily with negative indexing. Basically all indexing arithmetic is easier with zero
by naasking 2y ago
That's arguably one of the only downsides of zero-based, and can be handled easily with negative indexing. Basically all indexing arithmetic is easier with zero-based.
- tmtvl 2y agoUsing 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]'.