Machine-translated by Google. Questions are authored in English.
Top

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 ?

  • 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

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.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.