Two-dimensional arrays
Like a 1D array, a 2D array is a collection of data cells, all of the same type, which can be given a single name. However, a 2D array is organized as a matrix with a number of rows and columns.[2]
Daniel Shiffman[3] writes: an array keeps track of multiple pieces of information in linear order, a one-dimensional list. However, the data associated with certain systems (a digital image, a board game, etc.) lives in two dimensions. To visualize this data, we need a multi-dimensional data structure, that is, a multi-dimensional array. A two-dimensional array is really nothing more than an array of arrays (a three-dimensional array is an array of arrays of arrays). Think of your dinner. You could have a one-dimensional list of everything you eat:
(lettuce, tomatoes, steak, mashed potatoes, cake, ice cream)
Or you could have a two-dimensional list of three courses, each containing two things you eat:
(lettuce, tomatoes) and (steak, mashed potatoes) and (cake, ice cream)
Standards[edit]
- Construct algorithms using pre- defined sub-programmes, one- dimensional arrays and/or collections.