Fiveable
Fiveable

2-D Arrays

Definition

2-D Arrays (two-dimensional arrays) are rectangular grids or matrices consisting of rows and columns. They allow for storing and accessing elements using two indices - one for row number and another for column number.

Analogy

Imagine a chessboard where each square represents an element in the 2-D array. You can locate any piece on the board by specifying its row and column coordinates.

Related terms

Multidimensional Arrays: Multidimensional arrays extend beyond two dimensions (rows and columns). For example, a three-dimensional array adds depth as another dimension along with rows and columns.

Jagged Arrays: Jagged arrays are arrays where each row may have different lengths. This allows for more flexibility when dealing with irregularly shaped data structures compared to regular rectangular 2-D arrays.

Array Indexing: Array indexing refers to accessing or modifying elements in an array using their position or indices. In the case of 2-D arrays, you need to specify both the row and column index to access a particular element.



© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.