Recall & Review
beginner Click to reveal answer
What is preorder tree traversal?
Preorder traversal visits the root node first, then recursively visits the left subtree, and finally the right subtree.
beginner Click to reveal answer
In preorder traversal, which node is visited first?
The root node is visited first in preorder traversal.
beginner Click to reveal answer
What is the order of visiting nodes in preorder traversal?
The order is Root -> Left subtree -> Right subtree.
beginner Click to reveal answer
Show the preorder traversal output for this tree:
Root: 1
Left child: 2
Right child: 3
Root: 1
Left child: 2
Right child: 3
The preorder traversal visits nodes in this order: 1 -> 2 -> 3
intermediate Click to reveal answer
Why is preorder traversal useful?
Preorder traversal is useful to copy a tree or to get prefix expression of an expression tree because it visits the root before its children.
In preorder traversal, which node is visited second?
✗ Incorrect
After visiting the root, preorder traversal visits the left subtree first.
What is the correct order of nodes visited in preorder traversal?
✗ Incorrect
Preorder traversal visits root first, then left subtree, then right subtree.
Which traversal visits the root node before its children?
✗ Incorrect
Preorder traversal visits the root node first.
If a tree has root 5, left child 3, right child 7, what is preorder traversal?
✗ Incorrect
Preorder visits root first, then left, then right.
Which of these is NOT a use case of preorder traversal?
✗ Incorrect
Preorder traversal is not used for sorting elements.
Explain how preorder traversal works on a binary tree.
Think about the order of visiting nodes starting from the root.
You got /4 concepts.
Describe a real-life example where preorder traversal could be useful.
Consider situations where you need to process the main item before its parts.
You got /4 concepts.
