As part of the Java assignment, I have to take the input arithmetic expression and save it in a binary tree.
I did everything necessary for the assignment, except for the part where I read the expressions in a string and saved it in a binary tree.
I created a class called BinaryTree. Its only field is a treenode called root. This treenode is defined as an inner class in BinaryTree. It has 3 fields, a common data field and two child (left and right) BinaryTree types.
It is very difficult for me to define an algorithm for reading in an expression, for example
(5 * (2 + 3) ^ 3) / 2
and save it in a tree like this
/ ^ 2 * 3 5 + 2 3
Can anyone help with the algorithm?
HesNotTheStig
source share