In programming, don't think about multidimensional arrays in terms of traditional geometry unless you are trying to directly represent the world. It is better to think of each subsequent “dimension” as another array containing arrays. There are several use cases where this may appear. However, if you use more than three dimensions, I would no longer consider it as arrays or even "arrays of arrays", I prefer the trees to be closer to how you program that requires more than three levels.
One example is a tree where you have a root node that has nodes, which also have nodes. If you want to pick something, then a tree is a great tool. Let's say you wanted to sort a bunch of numbers that came in random order. You would make the first number that appeared in the root. If the first number is 5, and the next number is 7, then you should put 7 in the "right" root of node 5. And if you have 3, then 4, you must insert 3 to the "left" of 5, and then to 4 to the “correct” one from 3. If you cross this tree in order (always going left down the tree, we return only when there are no new nodes, and then to the right), you will get a sorted list: 3, 4, 5, 7.
5 / \ 3 7 \ 4
Here you can see the tree structure. If you did this in C, you would use structures that would look like this (I use pseudocode):
struct Node{ int val; Node left; Node right; }
There is a lot of material about binary trees (which I explain), but first of all I wanted you to move away from the concept of arrays, "as dimensions in space", and much more only from a data structure that can store elements. Sometimes a binary tree or other data structure is too complex, and a 5 or more dimensional array may be more convenient for storing data. I can’t come up with an example now, but they have been used before.
source share