ITPEC FE Morning October 2022 Question 8

Source exam: ITPEC FE Morning October 2022Topic: Basic Theory & Math

ITPEC FE Morning October 2022 — Question 8 of 80

Row-Major vs Column-Major Memory Mapping — count elements at the same address in both orderings.

For array A(5,5) with 1-based indexing, the position in a 1D array:

  • Row-major: pos = (i-1)*5 + (j-1)
  • Column-major: pos = (j-1)*5 + (i-1)

Set them equal:

  • (i-1)*5 + (j-1) = (j-1)*5 + (i-1)
  • 4(i-1) = 4(j-1)i = j

All main diagonal elements match: A(1,1), A(2,2), A(3,3), A(4,4), A(5,5)5 elements

Why not others:
- (a) 2, (b) 3, (c) 4 — the diagonal of an N×N matrix always has exactly N elements

Key rule: In an N×N array, row-major and column-major orderings place the same element at the same address only when i = j (the main diagonal), giving exactly N matches.

AI-generated — may contain errors

The original exam layout is preserved in the image so diagrams, formulas, tables, and code remain accurate.

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.