The GATE Grind

GATE 2015 CS (CS2) – Question 28

Compiler Design · Intermediate Code Generation · 1 mark · Multiple choice

Which statement about abstract syntax trees (ASTs) and control-flow graphs (CFGs) is true?

  1. A successor node always occurs later in source code in both AST and CFG
  2. For any input program neither AST nor CFG contains a cycle
  3. The maximum number of successors of a node in an AST and CFG depends on the input program
  4. Each AST and CFG node corresponds to at most one source statement

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) The maximum number of successors of a node in an AST and CFG depends on the input program

Explanation

AST branching depends on syntactic constructs and their number of children; CFG out-degree can depend on constructs such as multiway switches. Thus C. CFGs can contain loops, successor edges need not follow textual order, and a CFG basic block can contain several statements.

More Intermediate Code Generation questions

All Intermediate Code Generation questions →