Q: Given a binary tree, print the sum( inclusive of the root ) of sub-tree rooted at each node in in-order
This question can be answered in two ways. We can do it using two passes with constant space of with one pass and O( n ) space.
Lets say the tree node is as follows
No comments:
Post a Comment