A frame-buffer array for a monitor is stored in row-major order. Pixel…

2014

A frame-buffer array for a monitor is stored in row-major order. Pixel coordinates are written as (x, y), from (0, 0) through (100, 100), inclusive. What is the bit offset of pixel (6, 10) if the first pixel starts at offset 0 and each pixel uses one bit?

Answer: A. 1016ConceptIn a row-major two-dimensional buffer, complete rows are stored consecutively. For zero-based coordinates (x, y), x selects the column and y selects…

  1. A.

    1016

  2. B.

    1006

  3. C.

    610

  4. D.

    616

Attempted by 40 students.

Show answer & explanation

Correct answer: A

Concept

In a row-major two-dimensional buffer, complete rows are stored consecutively. For zero-based coordinates (x, y), x selects the column and y selects the row.

If each row has W pixels and each pixel occupies one bit, the bit offset is y × W + x. An inclusive coordinate range from 0 through n contains n + 1 positions.

Application

  1. The horizontal coordinate runs from 0 through 100, so the row width is W = 100 − 0 + 1 = 101 pixels.

  2. For pixel (6, 10), take x = 6 and y = 10.

  3. Substitute into the row-major formula: y × W + x = 10 × 101 + 6.

  4. Compute the offset: 10 × 101 + 6 = 1010 + 6 = 1016 bits from the start.

Contrast

  • 1006 uses a row width of 100 rather than the inclusive width 101.

  • 610 combines the swapped coordinate roles with a row width of 100.

  • 616 treats 6 as the row and 10 as the column, which reverses the stated (x, y) convention.

Cross-check

Ten complete rows occupy 10 × 101 = 1010 bits; moving six columns into the next row gives 1016. Therefore, pixel (6, 10) begins at bit offset 1016.

Explore the full course: Isro

Loading lesson…