0
You visited us 0 times! Enjoying our articles? Unlock Full Access!
Question

Representation of two dimensional array in memory is -
  1. Column-major
  2. Both (1) and (2)
  3. Row-major
  4. None of these

A
None of these
B
Column-major
C
Both (1) and (2)
D
Row-major
Solution
Verified by Toppr

Representation of two dimensional array in memory is row-major and column-major.

A 2D array has a type such as int[][] or String[][], with two pairs of square brackets. The elements of a 2D array are arranged in rows and columns, and the new operator for 2D arrays specifies both the number of rows and the number of columns.

A two-dimensional matrix a, two dimensional address space must be mapped to one-dimensional address space. In the computer's memory matrices are stored in either Row-major order or Column-major order form.

Row-major order and column-major order are methods for storing multidimensional arrays in linear storage such as random access memory.


924440_918877_ans_07fe416f8272415085dee97a5354f15d.PNG

Was this answer helpful?
16
Similar Questions
Q1
Representation of two dimensional array in memory is -
View Solution
Q2
Consider the following declaration of a two-dimensional array in C

char a[100][100];

Assuming that the main memory is byte-addressable and that the array is stored starting form memory address 0, the address of a[40][50] is
View Solution
Q3
Let A be a two-dimensional array declared as follows:

A: array [1...10] [1...15] of integer;

Assuming that each integer takes one memory location. The array is stored in row- major order and the first element of the array is stored at location 100. What is the address of the element A [i][j] ?
View Solution
Q4
Two dimensional representation of the earth is called a __________.
View Solution
Q5
Consider the following two C code segments. Y and X are one and two dimensional arrays of size n and n×n respectively, where 2n10. Assume that in both code segments, elements of Y are initialized to 0 and each element X[i][j] of array X is initialized to i + j. Further assume that when stored in main memory all elements of X are in same main memory page frame.

Code segment 1 :
// initialize elements of Y to 0
// initialize elements X [i][j] of X to i+j
for (i =0; i < n; i++)
Y [i] + = X [0] [i];

Code segment 2 :
// initialize elements of Y to 0
// initialize elements X[i][j] of X to i+j
for (i =0; i < n; i++)
Y [i] + = X [i] [0];

Which of the following statements is/are correct?

S1 : Final contents of array Y will be same in both code segments.

S2 : Elements of array X accessed inside the for loop shown in code segment 1 are contiguous in main memory.

S3 : Elements of array X accessed inside the for loop shown in code segment 2 are contiguous in main memory.
View Solution