Recall & Review
beginner
What is preorder tree traversal?
Preorder traversal visits nodes in this order: Root first, then Left subtree, and finally Right subtree. It means you process the current node before its children.
Click to reveal answer
beginner
In preorder traversal, which node is visited first?
The root node is visited first in preorder traversal before visiting any child nodes.
Click to reveal answer
beginner
What is the order of visiting nodes in preorder traversal?
The order is: Root → Left subtree → Right subtree.
Click to reveal answer
intermediate
Why is preorder traversal useful?
Preorder traversal is useful to copy a tree or to get prefix expression of an expression tree because it processes the root before its children.
Click to reveal answer
beginner
Show the preorder traversal output for this tree:<br><br> 1<br> / \
2 3<br> / / \
4 5 6
Preorder traversal visits nodes as: 1 → 2 → 4 → 3 → 5 → 6
Click to reveal answer
In preorder traversal, which node is visited immediately after the root?
✗ Incorrect
Preorder visits root first, then the left child (left subtree).
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 only one node, what is the preorder traversal output?
✗ Incorrect
Preorder visits root first, so the single node is visited.
Which of these is NOT a use case of preorder traversal?
✗ Incorrect
Sorting nodes in ascending order is usually done by inorder traversal in binary search trees.
Explain how preorder traversal works and the order in which nodes are visited.
Think about visiting the root before going down to children.
You got /4 concepts.
Describe a real-life example where preorder traversal would be useful.
Consider when you need to process a parent before its children.
You got /4 concepts.