Boundary Traversal Of A Binary Tree

easy
1. You are given a partially written BinaryTree class.
2. You are required to complete the body of boundaryTraversal function. The function is expected to print Boundary Traversal (anti clockwise) of the BinaryTree. All elements in an order must be separated by a arrow.
3. Input is managed for you.
4. NOTE: 
    ->Required Time Complexity : O(n)
    ->Required Space Complexity : O(1)
(kindly view sample question/solution video for more insight).

Input Format

Input is managed for you

Output Format

Boundary Traversal ,i.e. boundary elements of a Binary Tree(anti-clockwise). (separated by arrow)

Constraints

None

Example

Input
13
20 10 25 n n 39 n n 17 n 19 n n
Output
Boundary Traversal : 
20 -> 10 -> 25 -> 39 -> 19 -> 17 -> .
Previous
Diagonal Traversal Of A Bnary Tree
Next
Regular Expression Matching

Related Questions