in Compiler Design edited by
10,116 views
42 votes
42 votes

In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the following is TRUE?
 

  1. In both AST and CFG, let node $N_2$ be the successor of node $N_1$. In the input program, the code corresponding to $N_2$ is present after the code corresponding to $N_1$
  2. For any input program, neither AST nor CFG will contain a cycle
  3. The maximum number of successors of a node  in an AST and a CFG depends on the input program
  4. Each node in AST and CFG corresponds to at most one statement in the input program
in Compiler Design edited by
10.1k views

4 Comments

First statement is true for AST?
0
0

vishalshrm539 i dont think so ...cause for example for the code “a+b” for AST of this a will be a succesor of + but it’s appearing before + in the code {this is assuming that by "successor" we mean child of a node cause i dont think we can use "successor" defination used in context of BST here}

0
0

3 Answers

62 votes
62 votes
Best answer

Option (C) is Correct

  1. is false , In CFG , code of $N_2$ may be present before $N_1$ when there is a loop or Goto.
  2. is false , CFG contains cycle when input program has loop.
  3. is true ,successors in AST and CFG depend on Input program. 
  4. is false, In CFG a single node may belong to a block of statements.
edited by

4 Comments

I don't think these topics are in syllabus now.
0
0
they are in syllabus.
1
1
AST was always in syllabus. CFG is also in syllabus due to newly added code optimization section.
1
1
3 votes
3 votes
answer is c, but i'm not so sure
0 votes
0 votes
What does the line  the maximum number of nodes in ana AST and a CFG depend on input program  SAY in what sense do they mean
Answer:

Related questions