Skip to content
GATEiit

GATE CSE 2021 Set 1 Q14: Procedure calls and returns vs activation tree traversals

Question

Consider the following statements.

S1S_1: The sequence of procedure calls corresponds to a preorder traversal of the activation tree.

S2S_2: The sequence of procedure returns corresponds to a postorder traversal of the activation tree.

Which one of the following options is correct?

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 1/3 mark in GATE.
Show answer and explanation

Answer: C (official GATE 2021 final answer key)

Concept used: In an activation tree a node is entered before its children and returns only after all of them return.

First step: A call happens when its node is first visited (preorder); a return happens after all callees return (postorder).

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2021 Set 1 CS question paper and final answer key, organised by IIT Bombay. Question paper · Answer key