Most of the programming books I have ever read, have the following line:
"X language does not support true multidimensional arrays, but you can simulate (approximate) them with arrays of arrays."
Since most of my experience has been with C-based languages, i.e. C++, Java, JavaScript, php, etc., I'm not sure of what a "true" multidimensional array is.
What is the definition of a true multidimensional array and what languages support it? Also, please show an example of a true multidimensional array in code if possible.
Single dimensional array only stores single data or information like marks of the student. But in some cases, you have to store complex data which have rows and columns. So, a single dimensional array can't have this type of feature.
A multidimensional array in MATLAB® is an array with more than two dimensions. In a matrix, the two dimensions are represented by rows and columns. Each element is defined by two subscripts, the row index and the column index.
A multi-dimensional array is an array with more than one level or dimension. For example, a 2D array, or two-dimensional array, is an array of arrays, meaning it is a matrix of rows and columns (think of a table). A 3D array adds another dimension, turning it into an array of arrays of arrays.
In C programming, you can create an array of arrays. These arrays are known as multidimensional arrays. For example, float x[3][4];
C# supports both true multi-dimensional arrays, and "jagged" arrays (array of arrays) which can be a replacement.
// jagged array
string[][] jagged = new string[12][7];
// multidimensional array
string[,] multi = new string[12,7];
Jagged arrays are generally considered better since they can do everything a multi-dimensional array can do and more. In a jagged array you can have each sub-array be a different size, whereas you cannot do that in a multi-dimensional array. There is even a Code Analysis rule to this effect (http://msdn.microsoft.com/en-us/library/ms182277.aspx)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With