Discussion
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 ?
Answer: C
S1 is true and S2 is true.
In an activation tree each node is a procedure activation and its children are the calls it makes, in order. Calls happen when a node is first reached, parent before children, which is a preorder traversal. A procedure returns only after all the calls it made have returned, children before parent, which is a postorder traversal.
So both statements hold, and the options calling either of them false are wrong.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development