Question:

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 2, 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
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Step 1: Understanding activation trees.
An activation tree represents the hierarchy of procedure calls during program execution, where each node corresponds to a procedure invocation.

Step 2: Verification of Statement \( S_1 \).
In program execution, a procedure is recorded at the moment it is called, before its children are invoked. This corresponds exactly to a preorder traversal of the activation tree. Hence, \( S_1 \) is true.

Step 3: Verification of Statement \( S_2 \).
A procedure returns only after all its child calls have completed. This corresponds to a postorder traversal of the activation tree. Hence, \( S_2 \) is also true.

Step 4: Conclusion.
Since both statements are correct, the correct option is (C).

Was this answer helpful?
0
0