Question

In: Computer Science

What's the memory address for the following elements arrays given: Base Address: 1000, Dimensions: 10 rows,...

What's the memory address for the following elements arrays given:
Base Address: 1000, Dimensions: 10 rows, 5 columns, 4 byte elements.
Elements: 0,0; 9,4; 2,2; 4,1;
Base Address: 500, Dimensions: 10 rows, 15 columns, 4 byte elements.
Elements: 0,0; 9,14; 2,2; 4,11;
Base Address: 800, Dimensions: 4 rows, 5 columns, 2 byte elements.
Elements: 0,0; 3,4; 2,2; 3,4;

Solutions

Expert Solution

Solution:

(a)

Given,

=>Base address = 1000

=>Number of rows = 10

=>Number of columns = 5

=>Size of each element = 4 bytes

(i)

Explanation:

=>By default row-major order is assumed.

=>In row-major order first one full row is traversed before traversing another row,

Calculating address of 0,0:

=>Address of element = base address + size of element(i*number of rows + j*number of columns)

Where i = first index of array and j = second index of array

=>Address of element = 1000 + 4*(0*10 + 0*5)

=>Address of element = 1000

(ii)

Explanation:

Calcualting address of 9,4:

=>Address of element = 1000 + 4*(9*10 + 4*5)

=>Address of element = 1000 + 4*110

=>Address of element = 1000 + 440

=>Address of element = 1440

(iii)

Explanation:

Calcualting address of 2,2:

=>Address of element = 1000 + 4*(2*10 + 2*5)

=>Address of element = 1000 + 4*30

=>Address of element = 1000 + 120

=>Address of element = 1120

(iv)

Explanation:

Calculating address of 4,1:

=>Address of element = 1000 + 4*(4*10 + 1*5)

=>Address of element = 1000 + 4*45

=>Address of element = 1000 + 180

=>Address of element = 1180

(b)

Given,

=>Base address = 500

=>Number of rows = 10

=>Number of columns = 15

=>Size of each element = 4 bytes

(i)

Explanation:

Calculating address of 0,0:

=>Address of element = 500 + 4*(0*10 + 0*15)

=>Address of element = 500

(ii)

Explanation:

Calculating address of 9,14:

=>Address of element = 500 + 4*(9*10 + 14*15)

=>Address of element = 500 + 4*300

=>Address of element = 500 + 1200

=>Address of element = 1700

(iii)

Explanation:

Calculating address of 2, 2:

=>Address of element = 500 + 4*(2*10 + 2*15)

=>Address of element = 500 + 4*50

=>Address of element = 500 + 200

=>Address of element = 700

(iv)

Explanation:

Calculating address of 4,11:

=>Address of element = 500 + 4*(4*10 + 11*15)

=>Address of element = 500 + 4*205

=>Address of element = 500 + 820

=>Address of element = 1320

(c)

=>Base address = 800

=>Number of rows = 4

=>Number of columns = 5

=>Size of each element = 2 bytes

(i)

Explanation:

Calculating address of 0,0:

=>Address of element = 800 + 2*(0*4 + 0*5)

=>Address of element = 800

(ii)

Explanation:

Calculating address of 3,4:

=>Address of element = 800 + 2*(3*4 + 4*5)

=>Address of element = 800 + 64

=>Address of element = 864

(iii)

Explanation:

Calculating address of 2,2:

=>Address of element = 800 + 2*(2*4 + 2*5)

=>Address of element = 800 + 2*18

=>Address of element = 800 + 36

=>Address of element = 836

(iv)

Explanation:

Calculating address of 3,4:

=>Address of element = 800 + 2*(3*4 + 4*5)

=>Address of element = 800 + 2*32

=>Address of element = 800 + 64

=>Address of element = 864

I have explained each and every part with the help of statements attached to it.


Related Solutions

Assume that A and B are MATLAB arrays with 10 rows and an equal number of columns (the number of columns is not given).
Assume that A and B are MATLAB arrays with 10 rows and an equal number of columns (the number of columns is not given). Important: Next, the expression "a single line of code" implies a single command or equality. In other words, the code: X=A+1; X=X+B; is considered to be TWO lines of code, even though it can be written as one line. (a) (3%) Write a single line of code which saves the first two rows of array A...
Write a procedure to calculate Average of numbers(integers) using Arrays. Send base address of array in...
Write a procedure to calculate Average of numbers(integers) using Arrays. Send base address of array in register $a1 and Array length in register $a2 to the procedure and return Average in register $v0 to main program.
1. I need a java program that prints the following rows of arrays, like shown [3,5,6...
1. I need a java program that prints the following rows of arrays, like shown [3,5,6 7, 61, 71, 9, 99, 999, 4, 1, 0] 2. I also need a program that prints the sum of all the arrays 3. and a third program that only prints the elements from row one. Thanks!
Explain succinctly how to solve the following problem efficiently: Given two arrays, determine which elements appear...
Explain succinctly how to solve the following problem efficiently: Given two arrays, determine which elements appear in both arrays
For the arrays x and y given below, use MATLAB to find all the elements in x that are greater than the corresponding elements in y.
For the arrays x and y given below, use MATLAB to find all the elements in x that are greater than the corresponding elements in y.x = [-3, 0, 0, 2, 6, 8] y = [-5, -2, 0, 3, 4, 10]
Given a system with 4M bytes of address space per process, 64M bytes of physical memory,...
Given a system with 4M bytes of address space per process, 64M bytes of physical memory, pages of size 1K bytes, and page table entries of 8 bytes. How many entries can fit in one page? Select one: a. 128 b. 1K c. 8 d. 64K Given a system with 16G bytes of address space per process, 8G bytes of physical memory, and pages of size 16K bytes. How many entries are there in a linear page table? Select one:...
Given a system with 2T bytes of address space per process, 1T bytes of physical memory,...
Given a system with 2T bytes of address space per process, 1T bytes of physical memory, and pages of size 32M bytes. How many entries are there in a linear page table? Select one: a. 64K b. 32K c. 32M d. 1T Given a system with 8G bytes of address space per process, 2M bytes of physical memory, and pages of size 2K bytes. How bits are needed to specify the virtual page number? Select one: a. 22 b. 10...
Given a system with 512G bytes of address space per process, 2G bytes of physical memory,...
Given a system with 512G bytes of address space per process, 2G bytes of physical memory, and pages of size 2K bytes. How bits are needed to specify the offset? Select one: a. 39 b. 28 c. 11 d. 20 Given a system with 4M bytes of address space per process, 8M bytes of physical memory, pages of size 8K bytes, and page table entries of 4 bytes. How many entries can fit in one page? Select one: a. 8K...
If we had 20,000(subscript 10) memory locations, what would be the least number of address lines...
If we had 20,000(subscript 10) memory locations, what would be the least number of address lines needed to describe each location? (Hint: Change 20,000 to binary or hex and determine the number of bits needed.)
Address the following and Explain: a) what happens when a strong base is added to a...
Address the following and Explain: a) what happens when a strong base is added to a solution that only has significant amounts of a weak base b) what happens when a strong base is added to a solution initially made up of significant amounts of a weak base and its conjugate acid
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT