Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write code for the three classes that in question please show me your output (Stack Application Infix to Postfix Conversion) Write a program that
Please write code for the three classes that in question
please show me your output
(Stack Application Infix to Postfix Conversion) Write a program that 2. uses the Stack class template to convert an infix arithmetic expression into a postfix arithmetic expression. In infix form, the operator of an arithmetic statement is in-between every pair of operands For example a + b a (b c) (a+b)*c In postfix form, the operands of an arithmetic statement appear followed by the operator One of the virtues of postfix form is that expressions can be written without the need for parentheses. Here are some examples of arithmetic expressions written in postfix form a b 1/ Equivalent to a + b a bc *// Equivalent to a (b c) a + c * // Equivalent to (a + b) * c Please write a C++ program that uses an operator stack to convert an infix arithmetic expression that the user enters into a postfix arithmetic expression. Users input the infix arithmetic expressions which only contains the operands, operators and parenthesis symbols. The character # marks the end of the expression. The operands are represented by single lowercase letters, i.e., a, b, c, d, etc, and the operators are +,-, * and / Assuming the expressions the users enter are all validated You may call the following functions in main function // checks if c is an operand bool is_operand (char c) return true; else return false; // checks if c is an operator +, -, , or / bool is_operator (char c) return true; else return false // return the precedence of an operator int get_operator_precedence (char op) int prec0; prec-l; else if (op-'*' 11 op-'/' ) prec2; else return prec: ree files shou this pro uesti 1) the file Stack.h which contains the definition and implementation of Stack class template, 2) the application file a2q2.cpp containing main) function, 3) a script file a2q2result containing result Here are the sample runs: The infix expression: a+b- (c+d)*e The postfix expression: ab+cd+e* The infix expression: a* (b+c)-e The postfix expression: abc+*e- (Deque) A deque is a data structure consisting of a list of items on which the following operations are possible: a. push (x) Insert item x on the front end of the deque. b. pop ) : Remove the front item from the deque and return it c. inject (x) Insert item x on the rear end of the deque. d. eject () : Remove the rear item from the deque and return it. Write routines to support the deque that take O(1) time per operation (the operations that take O(n) will be given 0 point). Write an application file a2q3.cpp containing main () function to test if Deque class works correctly. Three files should be submitted for this program question 1) the file Deque.h which contains the definition and n of Deque class template, 2) the application file a2q3.cpp containing main () function 3) a script file a2q3result containing result. Here are the sample runs: Push values in deque:123 45 Inject values in deque: 1 23 4 5 The front element popped out is 5 The rear element ejected out is !5 The front element popped out is 4 The rear element ejected out is 4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started