Recall & Review
beginner
What is the Boundary Traversal of a binary tree?
Boundary Traversal means visiting the nodes on the outer edge of the tree in a specific order: left boundary (top to bottom), leaves (left to right), and right boundary (bottom to top).
Click to reveal answer
beginner
Which parts of the binary tree are included in the boundary traversal?
The boundary traversal includes three parts: 1) Left boundary nodes (excluding leaves), 2) All leaf nodes, 3) Right boundary nodes (excluding leaves).
Click to reveal answer
intermediate
Why do we exclude leaf nodes when collecting left and right boundaries in boundary traversal?
Leaf nodes are excluded from left and right boundaries to avoid duplication because all leaf nodes are collected separately in the leaf nodes step.
Click to reveal answer
intermediate
In boundary traversal, how is the right boundary collected differently from the left boundary?
The right boundary is collected from bottom to top, so nodes are stored in reverse order before adding to the result, unlike the left boundary which is collected top to bottom.
Click to reveal answer
beginner
Show a simple JavaScript function signature for boundary traversal of a binary tree.
function boundaryTraversal(root) {
// root is the root node of the binary tree
// returns an array of node values in boundary order
}Click to reveal answer
Which nodes are visited first in boundary traversal of a binary tree?
✗ Incorrect
Boundary traversal starts with the left boundary nodes from top to bottom.
Why do we collect leaf nodes separately in boundary traversal?
✗ Incorrect
Leaf nodes are collected separately to avoid duplication since they can appear in both left and right boundaries.
How is the right boundary added to the result in boundary traversal?
✗ Incorrect
Right boundary nodes are added from bottom to top to maintain the correct boundary order.
Which of these nodes is NOT included in the left boundary during boundary traversal?
✗ Incorrect
Leaf nodes are excluded from the left boundary and collected separately.
What is the time complexity of boundary traversal in a binary tree with n nodes?
✗ Incorrect
Boundary traversal visits each node at most once, so the time complexity is O(n).
Explain the steps involved in performing a boundary traversal of a binary tree.
Think about the three parts of the boundary and how to avoid duplicates.
You got /5 concepts.
Describe how you would implement boundary traversal in code using simple helper functions.
Divide the problem into smaller parts for clarity.
You got /5 concepts.