What is the logic behind programming languages 0-indexing?

583 views

As someone who primarily uses R, I don’t understand why Python indexes lists starting from 0. I’m very slow at simple mental calculations and doing something like subsetting an array in Python often takes me several extra seconds.

I think I read that it has something to do with memory, but thats so much less of a consideration for people who only use high level languages.

In: Technology

9 Answers

Anonymous 0 Comments

The values in the array are stored in memory. Rather than explicitly store the address for each element in the array, the computer stores the address only for the beginning of the array. To access other elements of the array, you must specify an offset.

Naturally, to access the beginning of the array itself, the offset would be 0. So the index starts at 0.

You are viewing 1 out of 9 answers, click here to view all answers.