Hello guys,
I am a biggener in D.S, i need someone to give me the code of the following question please.
I will be so thankfull and helpfull with him\her.
Regards,
Data Structure
Write a program that converts an arithmetic infix expression into a postfix expression. There is one stack for holding operators and the numbers or variables (in the arithmetic expression) will be transferred to a postfix string, after that appending the operators from the stack to the postfix string.
Example:
Input: String Infix = “a + 5 – c * d + c / 2”
Output: String Postfix = “a5cd*–+c2/+”
Note applies the following rules to convert the infix expression to postfix expression:
1. If the current char (in the Infix string) is number or mathematical variable, transfer it to Postfix string, and go to the next char.
2. If the char is operator, perform:
a. if the stack is empty push the operator into the stack, and go to the next char.
b. if the current operator (in the Infix string) have higher precedence than the top of the stack, push the operator into the stack, and go to the next char.
c. if the current operator (in the Infix string) have the same or less precedence than the top of the stack, pop the top of the stack and transfer it to Postfix string.
3. If the Infix string finish pop all contents of the stack and append it to the string Postfix.
Configuration: Windows XP Internet Explorer 7.0
Hi,
|