Question: Several programming languages support 2-dimensional arrays, since addresses in the native hardware is in fact linear (i.e., 1D), the programming language is responsible for mapping

Several programming languages support 2-dimensional arrays, since addresses in the native hardware is in fact linear (i.e., 1D), the programming language is responsible for mapping the 2D address into a 1D address. In the this exercise, you are asked to write a function that maps a 2D address (i.e., i and j) into a 1D linear address, in addition to row and column, the function takes the base address of the 2D array and number of columns. (Refer to slide chapter 6/slide 36), below is a simplified version of the formula: linear_address for (i, j) = base_address + (i *n) + j, where n represents numer of columns in the 2D array, assume indices start at zero: Function prototype: def to_linear_address(i, j, base_address, n)

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 Databases Questions!