4.1 Two-Dimensional ArraysSome problems require the use of a two-dimensional array, which organizes data into rows and columns similar to a table or grid. The individual elements are accessed by specifying two indices, one for the row and one for the column, ![]() Figure 4.1.1: Sample arrays: (left) a 1-D array viewed as a sequential list and (right) a 2-D array viewed as a rectangular table or grid.
As we saw earlier, Python does not directly support built-in arrays of any dimension. But, in the previous chapter, we used the EzArrays module to create and work with one-dimensional hardware-supported arrays. Two-dimensional arrays are also very common in computer programming, where they are used to solve problems that require data to be organized into rows and columns. Since 2-D arrays are not provided by Python, we define the Array2D abstract data type for creating 2-D arrays. It consists of a limited set of operations similar to those provided by the one-dimensional Array ADT from the previous chapter. The Array2D ADT
|