Question:medium

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

Show Hint

Procedure calls follow preorder traversal, while procedure returns follow postorder traversal of the activation tree.
Updated On: Jan 30, 2026
  • \( S_1 \) is true and \( S_2 \) is false
  • \( S_1 \) is false and \( S_2 \) is true
  • \( S_1 \) is true and \( S_2 \) is true
  • \( S_1 \) is false and \( S_2 \) is false
Show Solution

The Correct Option is C

Solution and Explanation

Step 1: Meaning of an activation tree.
An activation tree captures the dynamic behavior of procedure calls during program execution. Each node represents a procedure invocation, and edges represent caller–callee relationships.


Step 2: Verification of Statement S1.
A procedure is recorded in the execution trace at the moment it is invoked, before any of the procedures it calls are executed.

This order corresponds exactly to a preorder traversal of the activation tree.

Hence, S1 is true.


Step 3: Verification of Statement S2.
A procedure returns control to its caller only after all procedures it invoked have completed execution.

This behavior matches a postorder traversal of the activation tree.

Therefore, S2 is also true.


Final Conclusion:
Since both statements S1 and S2 are correct, the appropriate answer is (C).

Was this answer helpful?
0