1,877 views
1 1 vote
                             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

Position:
Show:

Related questions

9 9 votes
2 answers 2 answers
23.4k
23.4k views