Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the program in C++ and take the screen-shot of the output. 1. Create a stack class using array (try to have just the minimum

Write the program in C++ and take the screen-shot of the output.

1. Create a stack class using array (try to have just the minimum function, e.g. push, pop).

image text in transcribed

9. Infix to Postfix) Write a program that converts an infix expression into an equivalent postfix expression. The rules to convert an infix expression into an equivalent postfix expresion are as follows: Suppose infx represents the infix expression and pfx represents the postfix expression. The rules to convert infx into pfx are as follows a. Initialize pfx to an empty expression and also initialize the stack. b. Get the next symbol, sym, from infx. b.1. b2. b3. If sym is an operand, append sym to pfx. If sym is (,push sym into the stack. If sym is ), pop and append all the symbols from the stack until the most recent left parenthesis. Pop and discard the left parenthesis. bA. If sym is an operator: Pop and append all the operators from the stack to pfx that are above the most recent left parenthesis and have cedence greater than or equal to sym. b.4.1. pre- b.4.2. Pus h sym onto the stack. . After processing infx, some operators might be left in the stack. Pop and append to pfx everything from the stack. In this progam, you will consider the following (binary) arithmetic opera- tors: +,-*, and/. You may assume that the expressions you will process are error free. Design a class that stores the infix and postfix string. The class must include the following operations: . getInfix Stores the infix expression . showInfix Outputs the infix expression . showPostfix Outputs the postfix expresion Some other . convertToPostfix Converts the infix expression into a postfix operations that you might need are the following expression. The resulting postfix expression is stored in pfx. precedence first operator is of higher or equal precedence than the second operator, it returns the value tue; otherwise, it returns the value false Determines the precedence between two operators. If the . Include the constructors and destructors for automatic initialization and dynamic memory deallocation

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

More Books

Students also viewed these Databases questions