UGC NET Paper 2 (Computer Science)Very hard

For the basic block t1 = a + b; t2 = t1 * c; t3 = a + b; t4 = t3 - t2, after building a DAG and eliminating common sub-expressions, the minimum number of three-address statements needed is:

  1. A. 3
  2. B. 4
  3. C. 2
  4. D. 5

Correct answer: A. 3

The DAG recognises that t3 recomputes the same value as t1, so t3's references are replaced by t1, leaving only t1 = a + b; t2 = t1 * c; t4 = t1 - t2.

More UGC NET Computer Science and Applications questions

Exams that ask this topic