GATE Computer ScienceHardGATE CS (PYQ pattern)
Only the lower triangle (i ≥ j) of a 10 × 10 matrix A[1..10][1..10] of 4-byte elements is stored, packed into consecutive words starting at address 3000. What is the address of A[7][4] if the triangle is stored row by row, and if it is stored column by column?
- A. 3096 row-wise, 3120 column-wise
- B. 3100 row-wise, 3124 column-wise
- C. 3096 row-wise, 3132 column-wise
- D. 3084 row-wise, 3108 column-wise
Correct answer: A. 3096 row-wise, 3120 column-wise
Row-wise: rows 1..6 hold 1 + 2 + … + 6 = 21 elements, then A[7][4] is the 4th of row 7: offset 21 + 3 = 24, address 3000 + 96 = 3096. Column-wise: columns 1..3 hold 10 + 9 + 8 = 27 elements, and column 4 starts at row 4, so A[7][4] is at position 7 − 4 = 3 in it: offset 30, address 3120.
More Compiler Design questions
- For G: S → A A; A → a A | b | ε, which statements are true? I. FOLLOW(A) = {a, b, }. II. G is LL(1). III. G is ambiguous. IV. G is LR(1).
- A DFA reads a binary number most-significant bit first (leading zeros allowed; the empty string counts as 0). How many states does the…
- The grammar S → S a b | S c | A S | x; A → A d | S y | z is transformed by the standard algorithm that removes (indirect and immediate)…
- For the code 1: i = 0; 2: s = 0; 3: L1: if i >= n goto L4; 4: t = a + i; 5: if t > m goto L2; 6: s = s + t; 7: goto L3; 8: L2: a = a - 1…
- For G: S → a B | a C d; B → b | ε; C → b c, which statements are true? I. G is LL(2). II. G is LL(3). III. G is LR(0). IV. G is SLR(1).
- Construct the LL(1) table of S → A B c | B d; A → a A | ε; B → b B | A. Which option lists exactly the multiply-defined cells?