1,144 views
1 votes
1 votes
                             0
                          /     \
                        5        7
                    /    \      /   \
                   6       4    1     3
                            \
                             9 

Tree  given in the form: (node value(left subtree)(right subtree))
For tree given above: (0(5(6()())(4()(9()())))(7(1()())(3()())))
Input format: K Tree
Output format: Sum
For example, for given tree:
Input: 2 (0(5(6()())(4()(9()())))(7(1()())(3()())))
Output: 14

I just want to know the basic logic using push and pop operation of stack ,since I think it is easy to work with stack here 

1 Answer

Related questions

8 votes
8 votes
2 answers
1
0 votes
0 votes
1 answer
4
radha gogia asked Mar 7, 2016
707 views
How many key comparisons are there , what is the lower bound and upper bound ? For calculating the lower bound , should we consider the case when the keys are all in non-...