Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Program using 4D array [closed]

I'm a first year computer engineering student and I'm quite new here. I have been learning Java for the past three and a half months, and C++ for six months before that. My knowledge of Java is limited to defining and using own methods, absolute basics of object-oriented programming like use of static data members and member visibility.

This afternoon, my computer programming prof taught us about multi-dimensional arrays in Java. About multi-dimensional arrays being simply arrays of arrays and so on. He mentioned that in nominal, educational programming, arrays beyond 2 dimensions are almost never used. Even 3D arrays are used only where absolutely essential, like carrying out scientific functions. This leaves next to zero use for 4D arrays as using them shows that "you're using the wrong datatype" in my prof's words.

However, I'd like to write a program in which the use of a 4D array, of any data type, primitive or otherwise, is justified. The program must not be as trivial as printing the elements of the array.

I have no idea where to begin, this is why I am posting this here. I'd like your suggestions. Relevant problem statements, algorithms, and bits and pieces of code are also welcome.

Thank you.

Edit: Forgot to mention, I have absolutely no idea about working with GUIs in Java, so please do not post ideas that implement GUIs.

like image 890
Prathamesh Avatar asked Apr 04 '11 14:04

Prathamesh


2 Answers

One use could be applying dynamic programming to a function that takes 4 integer parameters f(int x,int y,int z,int w). To avoid calling this expensive function over and over again, you can cache the results in a 4D array, results[x][y][z][w]=f(x,y,z,w);.

Now you just have to find an expensive integer function with arity of 4, oh, and a need for calculating it often...

like image 197
Ishtar Avatar answered Oct 19 '22 17:10

Ishtar


Being a physics student we have only 3 dimension of space but we have a 4th dimension which is time. So thinking in that way we can think of an array of any dimension(1D or 2D or 3D) whose values differ with time or an array which keeps the record of every array whose values changed with time. It seems to be quite known to us. For example the "ATTENDANCE REGISTER" which we usually have in our classroom.

This is my view to it.

That's it. Enjoy :-)

like image 20
lõōsêr xxx Avatar answered Oct 19 '22 19:10

lõōsêr xxx