GATE Computer ScienceHardGATE CS (PYQ pattern)
An array is declared A[L..10][−4..5] with 4-byte elements and stored in row-major order starting at address 1744. If the address of A[0][0] is 2000, what is the lower bound L, and how many bytes does A occupy?
- A. L = −6; 640 bytes
- B. L = −5; 640 bytes
- C. L = −7; 720 bytes
- D. L = −6; 680 bytes
Correct answer: D. L = −6; 680 bytes
Each row has 5 − (−4) + 1 = 10 elements = 40 bytes. &A[0][0] = 1744 + ((0 − L)·10 + (0 − (−4)))·4, so 256 = (−10L + 4)·4, giving −10L = 60 and L = −6. Rows −6..10 are 17 rows: 17 × 40 = 680 bytes (taking 16 rows is the off-by-one slip).
More Compiler Design questions
- For S → a A | b B; A → c A d | ε; B → c B d d | ε (augmented with S′ → S), count the reduce entries (state, terminal) in the ACTION…
- S → C C; C → c C | d is LR(0). In its LR(0) parsing table the reduce action for a complete item is written in every terminal column…
- For S → A b | B c; A → a A | ε; B → a B | ε (augmented), in how many LR(0) states is there a conflict, how many ACTION cells of the LR(0)…
- How many distinct LR(0) items does the grammar S → i E t S Z | a; Z → e S | ε; E → b have (do not augment it; an ε-production gives…
- 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…
- 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).