Performance of 2-dimensional array vs 1-dimensional array

后端 未结 6 1295
谎友^
谎友^ 2020-11-27 14:46

In C, is there a difference in time and space between an m×n 2-dimensional array vs a 1-dimensional array of length m×n (for large values of m and n)? Will accessing element

6条回答
  •  [愿得一人]
    2020-11-27 15:00

    I'm only guessing, but I would say that a 1d array is faster than a 2d array. However, it wouldn't be measurably faster. Kind of like $1,000,000.01 is more than $1,000,000.

    I'd use whatever is easier to code with.

提交回复
热议问题