ISRO 2014 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0144

A frame buffer array is addressed in row-major order for a monitor with pixel locations starting from (0,0) and ending with (100,100). A pixel location is written (x, y), where x is the column and y is the row, so each row holds the 101 pixels x = 0 to 100. What is the address of the pixel (6,10)? Assume one bit of storage per pixel and that the starting pixel location is at address 0.
  1. A
    1016
  2. B
    1006
  3. C
    610
  4. D
    616

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solution\[\boxed{\text{address}(x,y) = y \times (\text{pixels per row}) + x}\]Each row has \(101\) pixels (x = 0 to 100). Pixel (6,10) is in row \(y=10\), column \(x=6\):\[10 \times 101 + 6 = 1016\](Reading (6,10) as row 6, column 10 would give \(6\times101+10=616\); here the first coordinate is the column.)Answer: A

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com