9 votes 9 votes 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? $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 Compiler Design gatecse-2021-set1 runtime-environment normal 1-mark + – Arjun asked Feb 18, 2021 • retagged Nov 30, 2022 by Lakshman Bhaiya Arjun 6.6k views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply zxy123 commented Feb 18, 2021 reply Follow Share Option C, both are true? 1 votes 1 votes KineticKarm commented Sep 13, 2021 reply Follow Share These statements are directly copied from Aho-ullman book page no 432. see here 3 votes 3 votes This_is_Nimishka commented Dec 5, 2023 reply Follow Share Compiler Principles Techniques & Tools – by – Aho, Lam. Sethi & Ullman 0 votes 0 votes This_is_Nimishka commented Dec 5, 2023 reply Follow Share https://codingninjas.com/studio/library/activation-tree-in-compiler-design 0 votes 0 votes Please log in or register to add a comment.
Best answer 15 votes 15 votes Correct Answer: C $S_1$: Is true because to perform procedure calls, first parent function will call child functions and hence it resembles preorder. $S_2$: Is true because to return parent function , we must return child functions first. Hence it resembles post order. Sherrinford03 answered Feb 19, 2021 • selected May 5, 2021 by Arjun Sherrinford03 comment Share Follow See all 2 Comments See all 2 2 Comments reply KineticKarm commented Sep 13, 2021 reply Follow Share These statements are directly copied from Aho-ullman book page no 432. see here 7 votes 7 votes Zbkhn commented Nov 9, 2022 reply Follow Share calling sequence of activation record is always in preorder traversal while return is always postorder. 0 votes 0 votes Please log in or register to add a comment.
11 votes 11 votes Option C :- Both S1 and S2 are true. Consider the recursion tree :- fun(A) Procedure Calls :- A → B → C → D → E : Preorder // \\ Return :- C → D → B → E → A :Postorder fun(B) fun(E) // \\ fun(C) fun(D) Yashvir answered Apr 8, 2021 Yashvir comment Share Follow See all 0 reply Please log in or register to add a comment.
2 votes 2 votes when we call a procedure, it goes to the stack and as we know stack uses both pre-order and post-order traversal Both statements are correct :) Mohitdas answered Oct 5, 2021 • edited Oct 5, 2021 by Mohitdas Mohitdas comment Share Follow See all 0 reply Please log in or register to add a comment.