Computer Science EngineeringVery hardISRO SC
Three-address code: 1: x1 = x2 + 1; 2: x2 = x3 + 2; 3: x3 = x1 + 3; 4: x1 = x2 + 4; 5: x2 = x3 + 5; 6: goto 8; 7: x1 = x2 + 7; 8: if x1 < 8 goto 2; 9: if x1 < 9 goto 8; 10: x1 = x2 + 10; 11: x2 = x3 + 11; 12: x3 = x1 + 12; 13: x1 = x2 + 13. Using the standard leader rules (first instruction, every jump target, every instruction immediately after a jump), the number of basic blocks is
- A. 6
- B. 7
- C. 5
- D. 8
Correct answer: A. 6
Leaders are 1, 2, 7, 8, 9, 10; each leader starts one block, so 6 blocks.
Practise more Theory of Computation, Compilers & Digital Logic (ISRO CS) questionsTheory of Computation, Compilers & Digital Logic (ISRO CS): notes and key points
More Theory of Computation, Compilers & Digital Logic (ISRO CS) questions
- Using Sethi-Ullman labelling (a left leaf needs 1 register, a right leaf operand can be a memory operand and needs 0), the minimum number…
- In register allocation by graph colouring, the interference graph has nodes v0..v7 and edges v0-v1, v0-v3, v0-v4, v0-v5, v1-v2, v1-v3…
- A flow graph has blocks B1: use{a,d} def{b}; B2: use{a} def{b,d}; B3: use{d} def{a,b,c}; B4: use{a} def{}. Edges: B1->B2, B2->B3, B2->B4…
- Build the DAG for ((((c + a) + (b - a)) ((a b) + (b + a))) + (((a b) + (b + a)) + ((a b) + (b + a)))) using value numbering, treating +…
- A scanner uses maximal munch with identifiers [a-z][a-z0-9], decimals digits(.digits)?, and operators/punctuators including <<=, <<, <=…
- Nested procedures use static (access) links. A procedure at nesting depth 4 references a local variable declared in an enclosing procedure…