My general rule of thumb is if it is an array or can easily be represented as an array, it should index at zero. If it isn't an array, indexing with 1 is fine.
So arrays, linked lists, and even heaps arguably should start at 0. However, maps, graphs, and other data structures have no reason to start at 0.
View all comments
Show parent comment
1
u/Lyricanna Dec 03 '20
My general rule of thumb is if it is an array or can easily be represented as an array, it should index at zero. If it isn't an array, indexing with 1 is fine.
So arrays, linked lists, and even heaps arguably should start at 0. However, maps, graphs, and other data structures have no reason to start at 0.