BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI
WORK INTEGRATED LEARNING PROGRAMMES DIVISION
BITS-WIPRO Collaborative Programme: MS in Information Technology, YEAR-2012.
Abstract: The project is to solve an infix expression using a desk calculator. Input is given as an infix expression and output is obtained in a text file. Method followed to solve the expression is, the input is fetched from the input text document and converted to postfix notation using expression tree data structure, the resulted RPN expression is evaluated and the result is shown in output text file. Infix is converted to postfix because, it is easy for the compiler to execute the expression in postfix format. Commonly used data structures for evaluating expressions are stacks and expression trees, both of the above data structures are analyzed and concluded that expression trees are the best suited data structure for solving infix expression.
1.Introduction:
Consider a situation where you are writing a programmable calculator. If the user types in 10 + 10, how would you compute a result of the expression? You might have a solution for this simple expression. But what if he types in 3 * 2 / (5 + 45) % 10 ? What would you do then?
The expression that you see above is known as Infix Notation. It is a convention which humans are familiar with and is easier to read. But for a computer, calculating the result from an expression in this form is difficult. Hence the need arises to find another suitable system for representing arithmetic expressions which can be easily processed by computing systems. The Prefix and Postfix Notations make the evaluation procedure really simple. The calculator you will be working with uses Reverse Polish Notation (RPN), which avoids the ambiguities that can be caused by operator precedence and
References: [1] B. B. Welch. Practical Programming in Tcl and Tk, 3rd ed. 2000. [2] J. Zelle. Python Programming: An Introduction to Computer Science. 2004. [3] http://cplusplus.com/reference/stl/stack/ [4] http://www.drdobbs.com/184401948 - UML for C programming.