News for hackers. Stuff that matters.
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]'.