GATE / CS ARCHIVE

GATE CSE 2015 SET 2 / QUESTION 28

GATE CSE 2015 Set 2 Q28

Compiler Design · Intermediate Code · Full GATE CSE 2015 Set 2 paper

GATE 2015 Set 2, Q28 1 mark · MCQ
Report issue

Intermediate Code

Question 28, GATE 2015: About AST and CFG, which is true? A successors always correspond to later source code; B neither can contain a cycle; C maximum successors can depend on input program; D each node corresponds to at most one statement.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

AST node arity can vary with program constructs, and CFG successor counts can vary with multiway branches such as switch. Thus C under the general AST/basic-block CFG representation. CFGs can contain loop cycles, successors need not follow source order, and a basic block can contain several statements.

An AST can represent a construct with a variable number of operands or children, while a CFG can give a multiway branch many successor blocks. Thus a fixed universal successor count does not follow from the general names. CFG loop back-edges directly disprove B, and also disprove A’s assumption that all successors appear later in source. A basic-block CFG node can contain several sequential statements, disproving D. Different fixed-arity normalized intermediate representations are possible, but are not specified here.

Original paper, page 35 · Answer key