- 1
Help me understand 3 dimensional array
Array
6 ответов
+ 3
array => list of values
2d array => list of arrays (rows and columns)
3d array => list of 2d arrays (depths, rows and colums)
0
array => list of cells with values
array 2d => grid of cells with values
array 3d => cube of cells with values
in array 3d, the cube can be seen as a list of grid of cells with values
in array 2d the grid can be seen as a list of list of values
so the array 3d can be seen as list of lists of lists of values
in any languages...
each values stored in a 3d array are referenced using 3 indexes (as 2d arrays uses 2 indexes), but technically (both) can be referenced as simple array(s) with only one index... it's only help to visualize data to refer at values with n-indexed notation ^^
0
Consider:
let arr = [1, 2, 3]
Unidimensional Array. His elements can be accessed by one index coordinates.
E.g: arr[0] = 1
let arr = [[1, 2], [3, 4], [5, 6]]
Bidimensional Array. His elements can be accessed by two indexes coordinate (like a cartographic map).
E.g: arr[0, 1] = 2
arr[2, 1] = 6
let arr = [[1, 2, [3, 4]]], [5,[6,7]]]
Tridimensional Array. His elements can be accessed by three indexes coordinate
E.g: arr[0,1,0] = 3
arr[1,1,1] = 7
- 2
C++