Diagonal Traversal of Binary Tree
Given a binary tree, print the diagonal traversal of the binary tree.
Consider lines of slope -1 passing between nodes. Given a Binary Tree, print all diagonal elements in a binary tree belonging to same line.
In the above example lines of slope -1 are passed between nodes and the diagonal traversal will be: 2 5 9 7 6 11 4 2 5
Queue q, root of binary tree, Node* temp, Node* temp1
The algorithm is actually processing the right children and EnQueueing the left children for each parent node. The EnQueued children accts as nodes to be processed for next level.
Example with explanation:
Nodes are represented with their respective values for better understanding.