Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions