I have written an expression tree (binary tree) that works so that it gives priority to brackets.
However I need to add the functionality of BODMAS to the making of the tree. How would I do this so it can solve expressions such as :
1 + ((4 -2)*3)*3
I though about putting brackets around the times and divide parts of an expression so that it would do those bits first. Though this isn't the best way as it would not give precedence of divide over times, or precedence of add over subtract (although in a lot of cases this would not have an effect on the result)
I would like to point out that this is coursework, so the theory behind what I need to do would be brilliant.
Thanks
However I need to add the functionality of BODMAS to the making of the tree. How would I do this so it can solve expressions such as :
1 + ((4 -2)*3)*3
I though about putting brackets around the times and divide parts of an expression so that it would do those bits first. Though this isn't the best way as it would not give precedence of divide over times, or precedence of add over subtract (although in a lot of cases this would not have an effect on the result)
I would like to point out that this is coursework, so the theory behind what I need to do would be brilliant.
Thanks
Comment