I think it might done using function of following prototype: void func(node* root, deque<int>& d, const deque<int>::iterator& it);
I will add left child's value in it-1 if exists else create new... similarly for right child. and call the same function for each of the children to explore further.. Monish On Oct 15, 11:57 pm, SUMANTH M <[email protected]> wrote: > Hi, > > A binary tree is given we need to print vertical sums of nodes. for > example > > 1 2 3 4 5 > > | | 5 | | > | | / | \ | | > | | / | 8 | > | | / | / | \| > | 4 | / | 10 > | / | \ 9 | | > | / | \ | | > 7 | 6 | > | | | | | > | | | | | > ----------------------------------------------- > 7 4 20 8 10 > > Here we need to print sum 7,4,20,8,10. > > -Thanks -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
