GATE Computer ScienceEasyGATE CS (PYQ pattern)
Same function f(n) = 1 for n ≤ 2, else f(n − 1) + f(n − 2) + f(n − 3). Each activation record takes 28 bytes. What is the maximum stack space used by activation records during the evaluation of f(9)?
- A. 224 bytes
- B. 252 bytes
- C. 196 bytes
- D. 4396 bytes
Correct answer: A. 224 bytes
The first argument decreases by 1 on the longest path: f(9), f(8), …, f(2) are live together, 8 records × 28 = 224 bytes.
More Compiler Design questions
- The SLR(1) table of S → i E t S Z | a; Z → e S | ε; E → b has one shift-reduce conflict (shift e versus reduce Z → ε), resolved as yacc…
- G: S → a A d | b B d | a B e | b A e; A → c; B → c is LR(1) but not LALR(1). Which of these changes, each made on its own, makes the…
- Sethi–Ullman labelling (a leaf is 1 if it is a left child and 0 if it is a right child, since a right operand may come from memory; an…
- An SDD uses N → B N1 { N.val = B.val + 2 × N1.val } | B { N.val = B.val } and B → 0 { B.val = 0 } | 1 { B.val = 1 }. What is N.val at the…
- A SLR(1) parser for the augmented grammar S → id | id [ E ] | id ( E ); E → id parses "id [ id ]". What is the maximum number of grammar…
- Partition into basic blocks (leaders: the first statement, every jump target, every statement right after a jump): 1: i = 0; 2: L1: if i >…