>might not be that bad, but I think the parenthesis would get me.
I was wondering dat so I decided to do some research into it and build
one on the fly.
I think it can be done using syntax trees. Essentially, you have
to write your own grammer and parsing engine however, the idea would
be as follows:
For example if your expression is:-
Then you would have your engine parse it into a syntax tree as follows:
(+)
/ \
/ \
/ \
(*) (-)
/ \ / \
3 (/) 17 5
/ \
(+) 4
/ \
7 1
Evaluting the expression recursively from the bottom upwards yields the
correct solution.
Most of what I learnt from the binary search tree was obtained from narue'
handy tutorial's
www.eternallyconfuzzled.com
My binary tree syntax is a bit rusty in java so I did it in C, however, if I feel like it,
I might write one for java wen I get home from school. Tee he he.
Simple as pie kiddo.