What are the benefits of pseudo multidimensional arrays and are they more relevant in some languages than others?
For quite some time, I've been aware of pseudo-multidimensional arrays, whereby a multidimensional array is stored in a single dimensional array. Rather than accessing a value via multiple indexes: arr[row][col] //Standard Approach The value is retrieved using a single calculated index: arr[row * col + 1] //Pseudo Approach Both approaches make sense. However, I've always assumed the pseudo approach to be a practice more common in C and/or C++ for reasons I've not explored. TBH, I've never felt compelled to use this pseudo approach in C#, Java, Javascript, PHP, OBJ-C, Swift, Kotlin, Python, Ruby, or even in C or C++. My understanding is both methods reserve the same blocks of contiguous memory and therefore are actually 1D arrays under the hood anyway. On that note, what are the benefits of one method over the other and do these apply to all languages? Also, is one method considered a better practice over the other or is this a matter of preference?