English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

What determines when to use one over the other?

2006-08-28 11:00:12 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

Like every thing it depends on the type or problem you want to solve your computer needs and the lines of code you want to use. and how you want to manage your memory.

Multidimensional arrays come very handy for numerical applications like matrices calculations. or when assigning two or more characteristics to a data variable. making the access simpler (less code lines)

so as you see the main point is to know how the management of data will be done and which operation you will make on such data.

2006-08-28 11:55:58 · answer #1 · answered by Tlalticpac 3 · 0 0

It depends on your personal style and some efficiency issues. Anything you can do with one, you can do with the other. Think of the screen with a resolution of 640x480. This is perfectly suited for a two dimensional array: screen[640][480] so to access any pixel on the screen you would find it with the x and y coordinates on the screen.

However, the (depending on the graphics mode) screen is really not made up of a 2D array but a linear array so you can also do screen[640*480].

In terms of run performance, the linear is a tad bit faster so if you were trying to squeeze every last bit of performance then you could go with the linear array, but it would be at the cost of increasing the complexity if your code because you will have to do a calculation to find the same pixel: screen[row*640+480]

In short, it doesn't matter how you implement it -- thats your individual coding style. But if you can visualize data as a multi dimensional array (like a multiplication table) then its just natural to go that way.

2006-08-28 23:01:21 · answer #2 · answered by soulblazer28 2 · 0 0

The data you store and how you are going to access it!
Mostly it is single lists. This will give you a one dimensional array.

But if for each item there is a corresponding 5 items this then is your two dimensional array.

2006-08-28 18:09:08 · answer #3 · answered by AnalProgrammer 7 · 0 0

fedest.com, questions and answers