Boundary traversal is a Binary tree traversal technique. It includes:
left boundary (nodes on left excluding leaf nodes)
leaves (consist of only the leaf nodes)
right boundary (nodes on right excluding leaf nodes)
Input: Binary tree
Output: Boundary traversal (visiting the boundary nodes of the tree in anticlockwise direction, starting from root node)
Approach: Dividing the problem into three parts: left boundary, bottom boundary and right boundary and performing the traversal using recursion.
Issue details
Problem statement: Given a Binary Tree, the objective is to perform boundary traversal.
Test Case:
Input: Binary Tree: [1 2 7 3 -1 -1 8 -1 4 9 -1 5 6 10 11]
Output: Boundary Traversal: [1, 2, 3, 4, 5, 6, 10, 11, 9, 8, 7]
Explanation:
Starting from the root, we traverse from: 1
The left side traversal includes the nodes: 2, 3, 4
The bottom traversal include the leaf nodes: 5, 6, 10, 11
The right side traversal includes the nodes: 9, 8, 7
We return the root and the boundary traversal is complete.
What would you like to Propose?
Boundary traversal is a Binary tree traversal technique. It includes: left boundary (nodes on left excluding leaf nodes) leaves (consist of only the leaf nodes) right boundary (nodes on right excluding leaf nodes)
Input: Binary tree Output: Boundary traversal (visiting the boundary nodes of the tree in anticlockwise direction, starting from root node)
Approach: Dividing the problem into three parts: left boundary, bottom boundary and right boundary and performing the traversal using recursion.
Issue details
Problem statement: Given a Binary Tree, the objective is to perform boundary traversal.
Test Case: Input: Binary Tree: [1 2 7 3 -1 -1 8 -1 4 9 -1 5 6 10 11] Output: Boundary Traversal: [1, 2, 3, 4, 5, 6, 10, 11, 9, 8, 7] Explanation: Starting from the root, we traverse from: 1 The left side traversal includes the nodes: 2, 3, 4 The bottom traversal include the leaf nodes: 5, 6, 10, 11 The right side traversal includes the nodes: 9, 8, 7 We return the root and the boundary traversal is complete.
Additional Information
No response