Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the expression, A+(BxC)/D [Note that the expression use x for multiplication instead of * so please reflect this in your answer] convert it into

Given the expression,

A+(BxC)/D [Note that the expression use x for multiplication instead of * so please reflect this in your answer]

convert it into PRN postfix by showing your working in the given table using the algorithm below.

image text in transcribed

The initial values are given to you. Answer format: Your typed-in answers MUST NOT have any white space e.g. ABx is typed in without any white space

Token Output/Postfix Stack Reason
A+(BxC)/D empty empty token is operand, output token to postfix
A Answer token is operator and precedence > than top element in stack, push token into stackno input remain, pop alltoken is ) so pop all until ( is found and discard both parenthesestoken is operand, output token to postfixtoken is (, push onto stack
Answer token is ) so pop all until ( is found and discard both parenthesesno input remain, pop alltoken is operator and precedence > than top element in stack, push token into stack token is operand, output token to postfixtoken is (, push onto stack
Answer token is operand, output token to postfixno input remain, pop alltoken is operator and precedence > than top element in stack, push token into stack token is (, push onto stacktoken is ) so pop all until ( is found and discard both parentheses
Answer token is operator and precedence > than top element in stack, push token into stacktoken is (, push onto stacktoken is operand, output token to postfixtoken is ) so pop all until ( is found and discard both parenthesesno input remain, pop all
Answer token is operand, output token to postfix token is ) so pop all until ( is found and discard both parenthesesno input remain, pop all token is operator and precedence > than top element in stack, push token into stacktoken is (, push onto stack
Answer token is operator and precedence > than top element in stack, push token into stacktoken is ) so pop all until ( is found and discard both parentheses token is operand, output token to postfixtoken is (, push onto stack no input remain, pop all
Answer no input remain, pop alltoken is operator and precedence > than top element in stack, push token into stacktoken is ) so pop all until ( is found and discard both parenthesestoken is (, push onto stack token is operand, output token to postfix
Answer token is operand, output token to postfixno input remain, pop alltoken is operator and precedence > than top element in stack, push token into stacktoken is (, push onto stacktoken is ) so pop all until ( is found and discard both parentheses
empty Answer token is (, push onto stack token is operator and precedence > than top element in stack, push token into stacktoken is operand, output token to postfix no input remain, pop all into postfixtoken is ) so pop all until ( is found and discard both parentheses
Initialize an empty stack of operators get next token in infix expression YES NO end of infix expression switch( token) operand ) Push it onto the stack display it Pop and display stack items until the stack is empty Pop and display stack element until a left) is encountered, but don't display) If stack is empty or token has higher precedence than top stack element, then push token onto stack, otherwise, pop and display top stack element; then repeat the comparison of token with new top stack item terminate

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions