0

I have to write a program the accepts a fully parenthesized like "((3*4)+(2-(4/2)))", or (3+5). It builds a tree for the expression, without the parentheses. So the tree for the (3+5) would be - "+" is the root, and the 3 is the left node and the 5 is the right node.

So its really an Expression Tree.

In one of my methods I have to count and return the number of operations, and I have to do it recursively. I'm having some trouble with the logic.

I had one method were I had to return the postFix notation of the expression recursively like this-

```
public String asPostfix()
{
return asPostfix(root);
}
public String asPostfix(ExpNode subTree)
{
if (subTree == null)
return "";
else
return asPostfix(subTree.left) + " " + asPostfix(subTree.right) + subTree;
}
```

But its a little bit different traversing the tree when I have to return on int.

Any tips would be appreciated.