Re:Numbering should start at zero: E.W. Dijkstra
by tmtvl on Friday March 21, 2025 @08:38AM
(#43434919)
But on the other hand,
is nicer than
so in the end I'd say 'de gustibus non est disputandum' and people who prefer 0-based indexing can use most languages and I can dream of my own.
[ Parent
| on HN ]
Re:Numbering should start at zero: E.W. Dijkstra
by naasking on Friday March 21, 2025 @12:49PM
(#43437992)
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.
Re:Numbering should start at zero: E.W. Dijkstra
by tmtvl on Friday March 21, 2025 @01:10PM
(#43438291)
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]'.