Before we can solve harder array problems, we need to be clear about one small but important idea: what is a "dimension"?
Think of a dimension as one direction you can move in. Each direction is independent of the others — moving in one does not affect the others.
We live in a three-dimensional world, so picturing up to three dimensions feels natural.
In math, there is a precise way to say this: the dimension of an object is the smallest number of coordinates you need to point to any single spot inside it. On a line you need 1 number. On a flat sheet you need 2 numbers. In a solid block you need 3 numbers.
Arrays follow the exact same idea. The dimension of an array is how many index numbers you must give to reach one single value.
value1 value2 value3. You need one index to pick a value. Think of it as a single line.So for arrays, the three everyday directions get the names row, column, and depth.
We cannot *picture* anything past three dimensions — but math has no such limit. We can create and work with arrays that have any number of dimensions. When an array has N dimensions, we call it an N-dimensional array or a multidimensional array. These two terms mean exactly the same thing.
Once we pass three dimensions, the friendly words *row, column, depth* run out. So we switch to a clean mathematical description instead. An N-dimensional array has sizes for each dimension, written as D1, D2, D3 ... Dn, where Di is the size of the i-th dimension. Its total shape is:
(D1 x D2 x D3 ... Dn)
Here is the part that surprises beginners. In math we naturally write the sizes from lower to higher: D1 x D2 ... Dn.
But almost all programming languages write them the other way — from higher to lower:
Dn x Dn-1 x Dn-2 ... D1
So when you actually *define* an array in code, the dimensions are listed as:
array [Dn][Dn-1] ..... [D1]
The same higher-to-lower order is used when you access one item. If the coordinate of the item is (I1, I2, I3, ... In), you read it in code as:
array [In][In-1] ..... [I1]
This higher-to-lower notation is also what the computer uses internally to calculate the base address of an item — the exact memory location where that value sits.
A dimension = one index you must supply. The number of indices is the number of dimensions. And remember: math lists dimensions low→high, but code lists them high→low.