Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Convert expressions that are in infix notation to postfix notation. The expressi

ID: 3888355 • Letter: C

Question

Convert expressions that are in infix notation to postfix notation. The expressions might contain parenthese and these operators: =, ONLY, NEVER, AND, OP.

Precedence rules: 1)Evaluate contents in () before others 2) =, NEVER, ONLY - high precedence 3) AND, OR - lower precedene

Need to create this function: int convertToPostfix(char * pszInfix, Out out)

For modularity, you will need to divide convertToPostfix into multiple functions.

Error Handling: code must handle erroes like: missing "(", ")". When an error is encountered, your code for convertToPostfix shoud return a non-zero value to the driver.

Make certain free up allocated memory.

Explanation / Answer

The simplest answer is that if you put everything into one class, you have to worry about everything at once when you're writing new code. This may work for small projects, but for huge applications (we're talking hundreds of thousands of lines), this quickly becomes next to impossible.

To solve this issue, you break up pieces of functionality into their own classes and encapsulate all the logic. Then when you want to work on the class, you don't need to think about what else is going on in the code. You can just focus on that small piece of code. This is invaluable for working efficiently, however it's hard to appreciate without working on applications that are huge.

Of course there are countless other benefits to breaking your code into smaller pieces: the code is more maintainable, more testable, more resusable, etc., but to me the largest benefit is that it makes massive programs manageable by reducing the amount of code you need to think about at one time.

I am working on how to convert a infix to postfix expression and then calculate that converted postfix expression. I have the following thought process on how to do this.

Receive a infix expression (Through the main file)

Instantiate the variables in this expression through a function called InstantiateVariable(char, int)

a + (2 + 2)

where a = 2; THUS the values must be added accordingly before it can be parsed and converted into the postfix

After the infix expression is received and the variables are instantiated, I want to "convert" this infix into a postfix expression in my shuntingYard function. Which I have managed to do and its working.

Lastly, I want to calculate/evaluate this postfix expression that was created in my shuntingYard function.