Recall & Review
beginner
What is the order of visiting nodes in Preorder Tree Traversal?
In Preorder traversal, nodes are visited in this order: Root first, then Left subtree, and finally Right subtree.
Click to reveal answer
beginner
Show the Preorder traversal output for this tree:<br>Root: 1, Left child: 2, Right child: 3
The Preorder traversal visits nodes as Root-Left-Right.<br>Output: 1 -> 2 -> 3
Click to reveal answer
beginner
What is the base case in a recursive Preorder traversal function?
The base case is when the current node is nullptr. Then, the function returns without doing anything.
Click to reveal answer
intermediate
Why is Preorder traversal useful in copying a tree?
Because Preorder visits the root before children, it allows copying the root node first, then recursively copying left and right subtrees, preserving structure.
Click to reveal answer
beginner
Write the recursive steps for Preorder traversal in simple words.
1. Visit the current node (root).<br>2. Traverse the left subtree in Preorder.<br>3. Traverse the right subtree in Preorder.
Click to reveal answer
In Preorder traversal, which node is visited first?
✗ Incorrect
Preorder traversal always visits the root node first before its children.
What is the correct Preorder traversal sequence for this tree?<br>1<br>/ \<br>2 3
✗ Incorrect
Preorder visits root first (1), then left child (2), then right child (3).
Which traversal order is Preorder?
✗ Incorrect
Preorder traversal visits root first, then left subtree, then right subtree.
What happens when the recursive Preorder function reaches a null node?
✗ Incorrect
The base case for recursion is when node is null, so the function returns immediately.
Which of these is NOT a use case of Preorder traversal?
✗ Incorrect
Printing nodes in sorted order requires Inorder traversal, not Preorder.
Explain how Preorder traversal visits nodes in a binary tree.
Think about the order Root, Left, Right.
You got /4 concepts.
Describe a simple recursive function for Preorder traversal.
Remember the base case and the three main steps.
You got /4 concepts.