Given a binary tree, print the diagonal traversal of the binary tree. Example 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 th...
// Function to print the diagonal elements of a given binary tree voidprintDiagonal(Node*root) { // create an empty map to store the diagonal element in every slope unordered_map<int,vector<int>>map; // perform preorder traversal on the tree and fill the map ...