GATE 2021 CS – Question 14
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?
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.