Question: a) Using stacks, give an algorithm to change prefix notation to postfix notation. b) Show the stack implementation of an algorithm that would check if

a) Using stacks, give an algorithm to change prefix notation to postfix notation. b) Show the stack implementation of an algorithm that would check if the following the expression of paranthesis is balanced. ({}{()}) c) What is the state of the stack after the following sequence of pushes and pops: Stack s; s.push ( 3 ); s.push ( 5 ); s.push ( 2 ); s.push ( 15 ); s.push (42); s. pop (); s. pop (); s.push (14); s.push ( 7 ); s. pop () ; s.push ( 9 ); s. pop (); s. pop (); s.push (51); s. pop (); s. pop (); d) Evaluate the following postfix expressions: 123+456++123+45+6+12+3456++ e) Suppose the numbers 0,1,2,,9 were pushed onto a stack in that order, but that pops occurred at random points between the various pushes. Show with work if the following sequences can be sequences of pops. (a) 2,3,1,5,4,7,6,0,9,8 (b) 2,3,1,0,7,6,5,4,9,8
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
