Could you be a little more specific?
What you may be looking for is column major and row major order. Usually, a static array is stored as a contiguous block of memory, you simply have to choose whether they're stored sequentially as columns or rows.
Another answer to another interpretation of your question would be either linearized storage in contiguous memory or indirection using an array of pointers referencing contiguous memory cells representing each column/row (see first answer). The latter option allows for ragged arrays.
If that's not what you're looking for, then I have no clue what to say, since I can imagine several ways to store an array in memory.
2007-01-12 03:06:06
·
answer #1
·
answered by Phillip W 2
·
0⤊
0⤋
You can use associative or numeric array types.
A numeric array simply uses integer indexes.
An associative array (also map, hash, dictionary, finite map, lookup table, and in query-processing an index or index file) is an abstract data type composed of a collection of keys and a collection of values, where each key is associated with one value. The operation of finding the value associated with a key is called a lookup or indexing, and this is the most important operation supported by an associative array. The relationship between a key and its value is sometimes called a mapping or binding. For example, if the value associated with the key "bob" is 7, we say that our array maps "bob" to 7. Associative arrays are very closely related to the mathematical concept of a function with a finite domain. As a consequence, a common and important use of associative arrays is in memoization.
From the perspective of a programmer using an associative array, it can be viewed as a generalization of an array: While a regular array maps integers to arbitrarily typed objects (integers, strings, pointers, and, in an OO sense, objects), an associative array maps arbitrarily typed objects to arbitrarily typed objects. (Implementations of the two data structures, though, may be considerably different.)
2007-01-12 10:59:06
·
answer #2
·
answered by Linux OS 7
·
0⤊
0⤋
#1 - Store a 3D array as an array of array of arrays. In other words, think of the 3D array as a 2D array where each element is an array itself. This is the most common and intuitive technique.
#2 - Store a 3D array as a 3 coordinate key with a value. So, the element at [1,2,3] could be stored in a HashMap at key "1,2,3". Works wonderfully for sparse arrays/matrices.
Of course, the two above techniques could be applied to n-dimensional arrays - I used the 3D arrays only for illustration.
2007-01-12 11:02:20
·
answer #3
·
answered by Zapata 2
·
0⤊
0⤋
The right way - creating a multi-dimensional array using your programming language's standard convention.
The wrong way - creating separate arrays, not creating an array at all, or trying to create a multidimensional array when you don't know how to program.
2007-01-12 11:15:18
·
answer #4
·
answered by Not a punk like you 2
·
0⤊
0⤋
All the answers above are correct, but if you're asking HOW, then you can use either direct initialization like:
Cell[i,j] = 3
or you could use nested loops to first store either column or row at index 0 in the outter loop and increment and then have the inner loop do the other.
the verbage i've used is probably not right, but without looking it up, that's the way it works.
2007-01-12 11:28:34
·
answer #5
·
answered by The_Amish 5
·
0⤊
0⤋
row wise and column wise
as far explanation goes....
search for it!
2007-01-12 12:18:30
·
answer #6
·
answered by AM 3
·
0⤊
0⤋