This content has been marked as final.
Show 4 replies

1. Re: Char arrays is it the right soultion for this problem
807601 Dec 21, 2007 8:05 AM (in response to 807601)The easiest way to deal with nested expressions and order of operations (BODMAS) is to use a stack. A stack is a Last In, First Out list (LIFO). 
2. Re: Char arrays is it the right soultion for this problem
807601 Dec 21, 2007 9:30 AM (in response to 807601)A while back I had to write an exceltype spreadsheet application, and we had to evaluate expressions and functions.
The easiest way we found to do it was to use a binary tree created from reverse polish notation.
http://en.wikipedia.org/wiki/Reverse_Polish_notation
It should be fairly easy to do with a stack as well. 
3. Re: Char arrays is it the right soultion for this problem
807601 Dec 21, 2007 9:37 AM (in response to 807601)Anthony42 wrote:
Reverse Polish is a stack implementation. But first he will need to translate the infix operator precedence based notation into a postfix notation.
A while back I had to write an exceltype spreadsheet application, and we had to evaluate expressions and functions.
The easiest way we found to do it was to use a binary tree created from reverse polish notation.
http://en.wikipedia.org/wiki/Reverse_Polish_notation
It should be fairly easy to do with a stack as well.
If this wasn't homework the OP would be able to choose something other than the traditional grade school arithmetic model he describes as BODMAS. 
4. Re: Char arrays is it the right soultion for this problem
807601 Dec 22, 2007 8:45 AM (in response to 807601)thanks all, that really helped.