ZeroBased
Zerobased, or zero-based indexing, is a convention in which the first element of an indexed sequence is assigned the index 0. In many programming languages and data structures, positions within arrays, lists, strings, and other sequences are referred to by nonnegative integers starting at 0.
The rationale for zerobased indexing traces back to memory addressing and pointer arithmetic. The offset from
Languages that use zerobased indexing include C, C++, Java, Python, JavaScript, Go, and Rust, among many others.
Advantages of zerobased indexing include straightforward address computation, consistency with pointer arithmetic, and support for end-exclusive
Related concepts include end-exclusive ranges and one-based indexing. Zerobased is a widely used default in many
---