Consider the following statements : S1: The sequence of procedure calls…
2025
Consider the following statements :
S1: The sequence of procedure calls corresponds to a preorder traversal of the activation tree.
S2: The sequence of procedure returns corresponds to a postorder traversal of the activation tree.
Which one of the following options is correct ?
- A.
S1 is true and S2 is false
- B.
S1 is false and S2 is true
- C.
S1 is true and S2 is true
- D.
S1 is false and S2 is false
Attempted by 22 students.
Show answer & explanation
Correct answer: C
The sequence of procedure calls follows preorder traversal because each function is visited before its children. Procedure returns follow postorder since all child calls complete before returning to the parent.