1. I am trying to insert for example (-, (/, (*, 4, (+, 15, 10)), 7), 9) which is in prefix form into a binary tree and display it in binary tree like this:
| - |
| /| | 9 |
| * | | 7 |
| 4 | |+|
2. Then from there i perform the Transversals( Preorder,inorder,postorder,etc)
Can someone with an algorithms on how to do it. If there is a sample caode will be fine. My problem is how to parse the input
The ideas is like this:
that on the first call of parseBinaryOperations,
the inputString is your entire string, and the return values would be:
operation = "-"
leftOperand = "(/, (*, 4, (+, 15, 10)), 7)"
rightOperand = "9"
Since leftOperand = '(', then you know that you have to keep calling parseBinaryOperations (recursively - TBD). If the operand is not a '(', then you can insert a node.
I need help on this