What is the output of the following C++ code for a binary tree with root value 1, left child 2, and right child 3 during pre-order traversal?

Practice Questions

1 question
Q1
What is the output of the following C++ code for a binary tree with root value 1, left child 2, and right child 3 during pre-order traversal?
  1. 1 2 3
  2. 2 1 3
  3. 1 3 2
  4. 3 2 1

Questions & Step-by-step Solutions

1 item
Q
Q: What is the output of the following C++ code for a binary tree with root value 1, left child 2, and right child 3 during pre-order traversal?
Solution: Pre-order traversal visits the root first, then the left subtree, followed by the right subtree, resulting in the output '1 2 3'.
Steps: 0

Related Questions

Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely