Question: The process of converting an infix expression to a postfix expression is itself most easily accomplished using a stack. The following algorithm is due to

The process of converting an infix expression to a postfix expression is itself most easily accomplished using a stack. The following algorithm is due to Dijkstra (original article is hereLinks to an external site., wikipedia page is hereLinks to an external site.). The infix expression is scanned from left to right, and the postfix expression is developed and output during the scan. You will write operands to the output string as you encounter them, but you will tend to accumulate operators (+,-,*,-:, etc.) onto the stack. The steps are as follows:Examine the next element in the input.If it is an operand, output it; in other words, remove it from the input string and write it out to the output string.If it is an opening parenthesis, push it onto (move it to) the stack.If it is an operator (not a function), then:If the top of the stack is an opening parenthesis, then push the operator.If the operator has higher priority than the top of the stack (multiply and divide have higher priority than add and subtract), then push the operator.Else, leave the operator in the input string alone (leave it in the input string untouched), and instead pop the operator from the stack to output, and repeat step 4.If it is a closing parenthesis, pop operators from the stack to the output until an opening parenthesis is encountered. Then pop and discard the opening parenthesis from the stack and then discard the closing parenthesis from your input string.If there is more input, go to step 1.If there is no more input, unstack the remaining operands to the output. When you are done, there should be no input string nor stack remaining everything should be in the output string. Here is an example to show you what is expected. This follows an example from Appendix I. At each step, determine the rule # that tells you what to change rules 2 through 5 or rule 7. Rules 1 and 6 are like branches they tell you whether to continue or not but dont change whats in your table. Each time you identify which rule applies, write the # in the reason column, one per row, 2,3,4a,4b,4c,5, or 7. You can skip the comments and just include the rule # if you like. Try to do one rule per row.Image of table showing solution for sample problemNow that we have seen the example, see your assigned formula below. Your task is to repeat this process with the rules above. I have included a few more operators, and given each a precedence number below. When comparing whether to move an operator to the output or push it onto the stack, the precedence value is needed. Lower values have higher precedence. Parentheses have 0, so they always get processed with high precedence than anything else. There are 3 operators with precedence 2: ^,! and . Process those left-to-right in the order you encounter them they have equal precedence. To get the special symbols, you can just copy them from the table and paste them into your table, or you can hand-write it and paste the table back in as a photo replacing the one below.Order of precedence tableBegin by copying your equation into the Input columns first row and convert to postfix by moving operators and operands to output and/or stack. Also, please be aware of unary operations (i.e. an operation with one operand such as sin(a)!!!) Your equation is: axbcos(b)xc+(d-e)Input OutputStackRule #(s) UsedFill in the table above for partial credit. But copy your final output answer into the following field. Include no spaces, and upper-case letters only. When entering your final expression if you have to include alphabetical operators make sure they are also capitalized. Use the same symbols given in your input. You can copy and paste those characters into your answer if you don't quite know how to reproduce it on your keyboard. Please take some care with this so it has a prayer of being correctly auto-graded. Thank you, your friendly neighborhood instructor and teaching assistants :)Final formula: I need a table with 9 colums for the input , output, stack and rules of # used.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!