Question 26Asked in Bihar STET Paper 2 Computer Science (Class 11-12), 12 Sep 2023, Shift 2 + 1 more paper

For a 2-D array represented in row-major order, the index formula to access the element at row "i" and column "j" using the base address "B" is:

  1. AIndex = B + (i * n + j)
  2. BIndex = B + (j * n + i)
  3. CIndex = B + (i + j)
  4. DIndex = B + (i * m + j)
Show answerHide answer

Correct answer: (A) Index = B + (i * n + j)

Explanation

In row-major order the rows are stored one after another, so element (i, j) is at B + (i × n + j) for n columns (times the element size, taken as 1 here).

From Bihar STET Paper 2 Computer Science (Class 11-12) PYQ, 12 Sep 2023, Shift 2

This is question 26 of Bihar STET Paper 2 Computer Science (Class 11-12) PYQ, 12 Sep 2023, Shift 2. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.

Asked in 2 papers