| ▲ | nish__ 8 hours ago | |||||||||||||
Doesn't every language support multidimensional arrays? It's just an array of arrays, no? What am I missing? | ||||||||||||||
| ▲ | umanwizard 7 hours ago | parent [-] | |||||||||||||
An array of arrays is an extremely inefficient and error-prone way to represent multidimensional arrays. If I want a 1000x1000 array, representing it physically as a single 1000000-element array requires one allocation, and processing it element-by-element (assuming it's stored in the same order we're iterating over it) is sequential in memory and therefore very efficient. Representing it as 1000 separate 1000-element arrays requires 1000 allocations, and pointer-chasing every time we move from one row to the next. | ||||||||||||||
| ||||||||||||||