GateAI
Runtime Environments

GATE CSE 2021 Set 1 · Q4

MCQ1 markEasy

Time

Consider the following statements. S1:S_1: The sequence of procedure calls corresponds to a preorder traversal of the activation tree. S2:S_2: The sequence of procedure returns corresponds to a postorder traversal of the activation tree. Which one of the following options is correct?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) S1 is true and S2 is true

Runtime Environments

In compiler runtime environments:

  • An activation tree represents the activations of procedures during execution, where each node represents an activation and child nodes represent procedures called by that activation.

  • When a procedure is called, execution enters its activation before its sub-procedures are called. Therefore, the sequence of procedure calls corresponds to visiting the root before its children, which is a preorder traversal of the activation tree. Thus, statement S1S_1 is true.

  • When a procedure finishes, all activations of the procedures it called must have already completed and returned. Therefore, a procedure returns only after all its children have completed, which corresponds to visiting all children before visiting the parent node, i.e., a postorder traversal of the activation tree. Thus, statement S2S_2 is true.

Hence, both S1S_1 and S2S_2 are true, which corresponds to option (C).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Runtime Environments previous year question is Q4 of the GATE CSE 2021 Set 1 paper. Find more GATE CSE PYQs on Runtime Environments in Compiler Design, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Runtime Environments PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Runtime Environments in GATE CSE

Runtime Environments has 7 GATE CSE PYQs across 7 papers from 2012 to 2023. 4 of them are 1-mark MCQs like this one, and it is the only one in GATE CSE 2021 Set 1.

How GATE tests Runtime Environments

More from GATE CSE 2021 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2021 Set 1 · Q4 · MCQ

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?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.