Question: IMPORTANT: For this exercise, you will be defining a function which USES the Stack ADT. A stack implementation is provided to you as part of

 IMPORTANT: For this exercise, you will be defining a function which

IMPORTANT: For this exercise, you will be defining a function which USES the Stack ADT. A stack implementation is provided to you as part of this exercise - you should not define your own Stack class. Instead, your code can make use of any of the Stack ADT methods. Stack push(), pop(). peek(), size() and is_empty(). Write a function called get_postfix_expression() which takes a string, infix_expression as a parameter. The parameter string represents a mathematical expression in standard infix notation. For example: 2 * ( 6 + 3). The function should convert this infix expression to postfix. In this example, the result would be: 2 6 3 + * You can assume that the only operators used will be "+", "-", "*", and "/". Note that the input string will have a single space surrounding each number and each bracket (except for the very first and very last elements in the string). Here are a few more examples: 2 * 3 + 4 2 + 3 + 4 1 * 3 + 2 + 4 ( 1 + 2) * ( 3 + 4 ) 2 3 * 4 + 2 3 4 * + 1 3 * 2 4 + + 1 2 + 3 4 + * For example: Test Result print(get_postfix_expression('2 * ( 6 + 3))) 2 6 3 + * print(get_postfix_expression('3 + 4 * 7')) 34 7 * + Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Reset answer 1 v def get_postfix_expression(infix_expression)

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 Databases Questions!