Question: 1 . A useful application of two dimensional lists in programming is to represent grid - like structures. Consider the following grid of values: 0

1. A useful application of two dimensional lists in programming is to represent grid-like structures.
Consider the following grid of values:
0
1
2
3
4
5
6
7
8
9
10
11
(a) If we wanted to store this data in a two dimensional array, valueGrid, how would we ini-
tialize it so that we accessed elements in row-major order? (Row major order means that
we access the row first, then the column in the row: valueGrid[row][col] is the element at
(row, col) in our grid.
Ex: valueGrid[0][1] would be 4)
valueGrid =
(b) While we normally think of grids in row major order, sometimes it is helpful to use column-
major order (Column major order means that we access the column first, and then the
row; valueGrid[col][row] is the element at (row, col) in our grid. Ex: valueGrid[1][0] would
be 4). How would we initialize valueGrid so that we used column-major order for the grid
above?
valueGrid =
1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!