The GATE Grind

GATE 2021 CS – Question 14

Compiler Design · Runtime Environments · 1 mark · Multiple choice

Consider the following statements.
$S_1$: The sequence of procedure calls corresponds to a preorder traversal of the activation tree.
$S_2$: The sequence of procedure returns corresponds to a postorder traversal of the activation tree.
Which one of the following options is correct?

  1. $S_1$ is true and $S_2$ is false
  2. $S_1$ is false and $S_2$ is true
  3. $S_1$ is true and $S_2$ is true
  4. $S_1$ is false and $S_2$ is false

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) $S_1$ is true and $S_2$ is true

Explanation

A procedure is called before its children (preorder) and returns after all its children have returned (postorder). Both statements are true.