New answers tagged

1

This can indeed be solved in $O(n)$ time. What you mentioned (checking value of root, calling recursively for left and right subtree) almost works, the issue is just that we don't know the size of the right subtree, so we cannot immediately recursively solve the left subtree as we don't know where it ends. But this is not an issue: Just recursively solve the ...


-1

This is nothing but a $parse$ $tree$ of your expression. Now coming to your question, you cannot actually obtain something from any parse tree. Parse trees are used in an abstract concept in compilers (to be exact they are the output of syntax analysis phase of a compiler). What you can do, or your software can do is that, u can first simplify the equation ...


0

For solving this question you should assume a tree with '=' root And in the left side of root push factors of x and in the right side push your constant values, now variable x is equal to sum of right side division by left side.


Top 50 recent answers are included