GATE Computer ScienceModerateGATE CS (PYQ pattern)
A zero-address stack machine evaluates the expression (a + b) × (c + d) + (e + f) × (g + h) with every operator commutative, so the operands of each operator may be evaluated in either order. What is the least stack depth needed (counting each pushed operand and each intermediate result)?
- A. 3
- B. 5
- C. 8
- D. 4
Correct answer: D. 4
Leaves need 1; a sum of two leaves needs 2; a product of two such subtrees needs 2 + 1 = 3 (equal needs add one); the final sum of two equal subtrees needs 3 + 1 = 4.
Practise more Computer Organization and Architecture questionsComputer Organization and Architecture: notes and key points
More Computer Organization and Architecture questions
- A classic 5-stage pipeline (IF, ID, EX, MEM, WB) has no forwarding and no split-cycle register file: a value written in WB can be read in…
- A memory has 8 low-order interleaved banks (bank = address mod 8). A bank is busy for 6 cycles after starting an access; the processor can…
- An accumulator machine has memory contents M[100]=300, M[104]=7, M[150]=75, M[200]=150, M[300]=500 and registers R1 = 100, R2 = 4…
- A loop branch is taken 9 times and then falls through (T×9, N), and the whole 10-outcome pattern repeats 5 times. A 2-bit saturating…
- A control unit has 48 control signals partitioned into 6 groups of mutually exclusive signals of sizes 12, 10, 9, 8, 5 and 4. In a…
- A branch outcome stream is TTTTTNN repeated 6 times (42 outcomes). With a 2-bit saturating counter (taken predicted in states 2,3)…