Knowee
Questions
Features
Study Tools

Consider the following array declaration and use it to answer questions 46-49:int A[4][5][6];46. What will be the total memory in bytes that is to be reserved by the machine to store the dataitems in this array:a) 580 bytesb) 680 bytes#c) 480 bytesd) 380 bytese) 280 bytes47. If the machine is to store the data items in this array using row-major ordering, what will be theaddress location of an item located at A[2][3][5] if the base address is 200.a) 332b) 846c) 733# d) 532e) 63248. What will be the address of the same data item in question 47 above if the items in the arraywere stored using column-major ordering?a) 456b) 650#c) 656d) 556e) 532

Question

Consider the following array declaration and use it to answer questions 46-49:int A[4][5][6];46. What will be the total memory in bytes that is to be reserved by the machine to store the dataitems in this array:a) 580 bytesb) 680 bytes#c) 480 bytesd) 380 bytese) 280 bytes47. If the machine is to store the data items in this array using row-major ordering, what will be theaddress location of an item located at A[2][3][5] if the base address is 200.a) 332b) 846c) 733# d) 532e) 63248. What will be the address of the same data item in question 47 above if the items in the arraywere stored using column-major ordering?a) 456b) 650#c) 656d) 556e) 532

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The language of the text is English. Here are the answers to your questions:

  1. To calculate the total memory in bytes reserved by the machine to store the data items in this array, you need to multiply the size of each dimension by the size of the data type. Assuming that each item in the array is an integer and that an integer is 4 bytes, the total memory would be 4 bytes * 4 * 5 * 6 = 480 bytes. So, the answer is c) 480 bytes.

  2. In row-major ordering, the elements of the array are stored row by row. The formula to calculate the address of an element in a three-dimensional array is: base address + ((depth * NUM_OF_ROWS * NUM_OF_COLUMNS + row * NUM_OF_COLUMNS + column) * size of data type). Assuming that the depth is 2, the row is 3, the column is 5, the number of rows is 4, the number of columns is 5, and the size of the data type is 4 bytes, the calculation would be: 200 + ((2 * 4 * 5 + 3 * 5 + 5) * 4) = 532. So, the answer is d) 532.

  3. In column-major ordering, the elements of the array are stored column by column. The formula to calculate the address of an element in a three-dimensional array is: base address + ((column * NUM_OF_ROWS * NUM_OF_DEPTH + row * NUM_OF_DEPTH + depth) * size of data type). Using the same values as in the previous question, the calculation would be: 200 + ((5 * 4 * 4 + 3 * 4 + 2) * 4) = 656. So, the answer is c) 656.

This problem has been solved

Similar Questions

Consider the following array declaration and use it to answer questions 46-49:int A[4][5][6];46. What will be the total memory in bytes that is to be reserved by the machine to store the dataitems in this array:a) 580 bytesb) 680 bytes#c) 480 bytesd) 380 bytese) 280 bytes47. If the machine is to store the data items in this array using row-major ordering, what will be theaddress location of an item located at A[2][3][5] if the base address is 200.a) 332b) 846c) 733# d) 532e) 63248. What will be the address of the same data item in question 47 above if the items in the arraywere stored using column-major ordering?a) 456b) 650#c) 656d) 556e) 532

Where is an array stored in memory?

MEMORY SIZE OF THE INT DATA TYPE:

What is the size of array defined below in bytes? int a[] = new int[100];

How are elements stored in memory in a C array?

1/4

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.