Diagonal Traversal Of A Bnary Tree

easy
1. You are given a partially written BinaryTree class.
2. You are required to complete the body of diagonalTraversal function. The function is expected to print Diagonal Traversal of the BinaryTree. All elements in an order must be separated by a space.
3. Input is managed for you.
4. NOTE: 
    ->Required Time Complexity : O(n)
    ->Required Space Complexity : O(n)

Input Format

Input is managed for you

Output Format

Elements (space separated) of diagonal(s) line wise (Output is managed for you)

Constraints

None

Example

Input
13
20 10 25 n n 39 n n 17 n 19 n n
Output
Diagonal Traversal : 
20 17 19 
10 39 
25 
Previous
Iterative Postorder
Next
Boundary Traversal Of A Binary Tree

Related Questions