TheAlgorithms / Java

All Algorithms implemented in Java
MIT License
59.45k stars 19.17k forks source link

[FEATURE REQUEST] Add Boundary Traversal of Binary Tree Problem #5592

Open VShalini01 opened 3 days ago

VShalini01 commented 3 days ago

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

ssugam10 commented 3 days ago

kindly assign this issue to me

keshavkhetan123 commented 2 days ago

kindly assign this issue to me

Aastha-ojha-20 commented 2 days ago

kindly assign this issue to me