GATE Computer ScienceHardGATE CS
An array A[2..6][−1..4][0..5] of 4-byte elements has base address 1000. The address of A[4][2][3] is computed in row-major order and, separately, in column-major order. By how many bytes is the column-major address greater than the row-major address?
- A. 48
- B. 56
- C. 64
- D. 72
Correct answer: B. 56
The dimension sizes are 5, 6 and 6. Row-major offset = ((4 − 2)·6 + (2 + 1))·6 + 3 = 93 elements, so the address is 1372. Column-major offset = ((3·6 + 3)·5) + 2 = 107 elements, address 1428. The difference is 14 elements = 56 bytes.
More Compiler Design questions
- A scanner discards comments, which begin with / and end at the FIRST / (comments do not nest). Identifiers are letters, and and / are…
- A C lexer uses maximal munch. How many tokens does it produce for the line int x = a++ + --b >= 3 ? 1 : 0; (whitespace is ignored)?
- For the grammar S → A B c; A → a A | ε; B → b B | ε, how many terminals are in FIRST(S)?
- For the standard expression grammar E → T E′; E′ → + T E′ | ε; T → F T′; T′ → F T′ | ε; F → ( E ) | id, how many symbols (including ) are…
- How many states does the canonical LR(0) collection of the augmented grammar S′ → S; S → A A; A → a A | b contain?
- What is the number of states in the minimal DFA for the regular expression (a|b)abb?