10,116 views

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

First statement is true for AST?

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}

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.

I don't think these topics are in syllabus now.
they are in syllabus.
AST was always in syllabus. CFG is also in syllabus due to newly added code optimization section.
answer is c, but i'm not so sure
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
by