Visualizing a three dimensional array, and its length

To visualize a three-dimensional array, and to comprehend its length, you can think of it in terms of literal physical dimensions (remember the book Flat Land?).

One object:

.

An array of objects:

.............

The length of this array (array.length) is how many elements, or dots, counting from left to right.

A two-dimensional array of objects:

.............
.............
.............
.............
.............
.............

Each element in the previous array now has its own array, going down. The length of the first element in this array (array[0].length, the top-left-most) is counting the dots top to bottom.

A three dimensional array is like a cube (this is all assuming uniform lengths among elements)

.............
............. .
............. . .
............. . . .
............. . . .
............. . . .
   . . . . . . . . .
    . . . . . . . ..
     . . . . . . . .

Each element in the previous array now has its own array (going deep "into" the screen). The length of the first element in this array (array[0][0].length, the top-left-most element) is the number of dots deep.

Not once have I (directly) used a three dimensional array.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s