Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop c++ program to convert infix to postfix and evaluate the postfix expression: 1. Must use stack class with .h and.cpp seperate files 2.Priority =

Develop c++ program to convert infix to postfix and evaluate the postfix expression:

1. Must use stack class with .h and.cpp seperate files

2.Priority =

*, /

+, -

(

psudocode to implement:

Initialize an empty stack (for operators)

While not_finished parsing the expression

{obtain the next input token in the expression;

switch (token)

{case : break; //space

case (: push; break;

case ): pop & display popped element until ( is encountered;

//do not display the (

break;

case +, -, *, /, %: //( and ) are not considered as operators

if empty_stack or priority(token) > priority(stack_top)

push;

else

pop & display popped element until empty_stack or until

priority(token)<=priority(stack_top)

push

break;

case operand: display;

break;

} }

pop & display the rest of the stack elements; //do not display the (

}

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_2

Step: 3

blur-text-image_3

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

Database Management System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions

Question

1. What are the major sources of stress in your life?

Answered: 1 week ago