An operation that displays the contents of a stack can be useful during program
ID: 3930728 • Letter: A
Question
An operation that displays the contents of a stack can be useful during program debugging. Add a display method to the ADT stack (the stack class we studied in the class) such that The method uses only ADT stack operations; that is, it is independent of the stack's implementation. The method assumes and uses the pointer-based implementation of the ADT stack. Convert the following infix expression to postfix form by using the algorithm given in the class. Show the status of the stack after each step of the algorithm. a - b + c a - (b/c*d) a/(b*c) a/b/c - (d + e)*f (a + b)*c a*(b/c/d) + e a - (b + c) a - (b + c*d)/e What is the outputs of the following pseudocode, where num1, num2, num3 are Integer variables? num1 = 5 num2 = 1 num3 = 4 aQueue.enqueue(num2) aQueue.enqueue(num3) aQueue.dequeue() aQueue.enqueue(num1-num2) aQueue.dequeue(num1) aQueue.dequeue(num2)Explanation / Answer
HI, Friend, I have answered problem 3. Please do not post big problems in one post.
Please repost problem 4 separetly.
Problem 3)
/ and * have same precedence
+ and- have same precedence
AND, (/ *) have higher precedence than (+ -)
bracket has higest precedende
Also, + - * / = has Left to Right associativity
a)
a-b+c
= (ab-)+c
=ab-c+
b)
a-(b/c*d)
= a - (bc/ * d)
= a - (bc/d*)
= abc/d*-
c)
a/(b*c)
= a/(bc*)
abc*/
d)
a/b/c-(d+e)*f
= a/b/c-(de+)*f
= (ab/)/c-(de+)*f
= (ab/c/)-(de+)*f
= (ab/c/) - (de+f*)
= ab/c/de+f*-
e)
(a+b)*c
= (ab+)*c
= ab+c*
f)
a*(b/c/d)+e
= a*((bc/)/d)+e
= a*(bc/d/)+e
= (abc/d/*)+e
= abc/d/*e+
g)
a-(b+c)
= a - (bc+)
= abc+-
h)
a-(b+c*d)/e
= a - (b + (cd*))/e
= a -(bcd*+)/e
= a - (bcd*+e/)
= abcd*+e/-
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.