4 ms·
That is true for vectors, but not matrices, right? char at(char matrix[10][10], char i, char j) { return matrix[i][j]; } still has more computation on
by espadrine 4y ago
That is true for vectors, but not matrices, right?
char at(char matrix[10][10], char i, char j) {
return matrix[i][j];
}
still has more computation on 1-indexed than on 0-indexed, I believe.
- contravariant 4y agoWell you've either got: memory_address + array_width*i + j or memory_address + array_width*(i-1) + (j-1) = (memory_address-array_width-1)+ array_width*i + j so you can just absorb the extra computation into the pointer.