Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Practical Use for 4D+ Arrays [duplicate]

I have been studying Java and C++ this year, and I am wondering; what practical uses are there for a 4 or even 5 dimensional array? My teacher basically says that you are using the wrong datatype if you want to use a 4 dimensional array.

Have you ever used a 4 of 5 (or more) dimensional array? What did you use it for? What practical uses can you think of for them?

Thanks!

like image 385
agotsis Avatar asked Feb 25 '14 05:02

agotsis


Video Answer


2 Answers

A practical use of a 4D array is to keep track of a 3d object, could keep track of [x-cord][y-cord][z-cord][time]. This 4D array would be a useful use of a 4D array. This could keep track of a range of cords and time, and the value in the array could say the speed of of the object.

Speed = arr[5][9][6][1500];

That would record the speed of the object when it was at x cord 5, y cord 9, z cord 6, and say been alive for 1500 seconds.

As for your 5D array:

int left; //#of cars left in world
left = allCars[year][brand][color][condition][horsepower];

brand count be an int(have a table of values aka Ferrari = 1, same with color. Condition could be on a scale of 0 being destroyed, to 1 being brand new).

Then you could find the # of 1947 Ferrari's that are red in brand new condition with 200 horsepower.

Aka in general you could use many dimensional arrays to keep track of large databases of things.

like image 146
Lain Avatar answered Sep 25 '22 00:09

Lain


You may create a Sodoku hypercube with 4 dimensions and then you can store the number which the user enters into a 4dimensional int array.

Rotating 4D hypercube (GIF movie). Imagine a person who lives in 4 spatial dimensions, watching a hypercube rotate. The 4-dimensional person has a 3-dimensional retina in each of its 2 eyes (two eyes suffice for depth perception, even in 4D). Each retina records a 3-dimensional image.

This image shows what the 4-dimensional person sees, with the extra dimension shown as a variation in colour. That is, the horizontal, vertical, and `colour' directions correspond to the 3 directions on the 3-dimensional retina of the 4-dimensional person. The vertical bar to the right of the picture shows the correspondence between colour and position in the extra dimension.

Also you may check the Tesseract

like image 28
Rahul Tripathi Avatar answered Sep 23 '22 00:09

Rahul Tripathi