Answered step by step
Verified Expert Solution
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.
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 | ||
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