Jul 13, 2008 at 12:31pm UTC
hi
For 2D array we can navigate a pointer using row*no.of coloums+col arithmetic. similarly what is the arithmetic for navigating 3D dimensional array pointer.
Last edited on Jul 13, 2008 at 12:31pm UTC
Jul 13, 2008 at 1:10pm UTC
The same sort of thing.
For an array of [ A ][ B ][ C ], we can index it thus:
(a * B * C ) + (b * C ) + (c * 1)
Notice the pattern: for each dimension, its index is multiplied by the product of the cardinality of all dimensions minor to it.
To help digest that, here's another example. Given array[ A ][ B ][ C ][ D ]:
(a * B * C * D ) + (b * C * D ) + (c * D ) + (d * 1)
Hope this helps.