b. add c) push peek 9- Given the following infix expression, which one of the fo
ID: 3587086 • Letter: B
Question
Explanation / Answer
I didnot understand whether to answer all the questions or the missing parts of the last question. I am answering the missing part of last question as they are unfilled. Please comment for any further help.
11.
s.push(a); -->a
Pushing a as first element in the stack s
s.push(b); -->a-->b
Pushing b
s.push(c); -->a-->b-->c
Pushing c
t.push(d); -->d
Pushing d as first element in the stack t
t.push(s.pop()); -->d-->c
Popping the top int of s which is c and pushing in to t
t.push(s.peek()); -->d --> c --> b
Pushing the peek int of the stack s to stack t
s.push(t.pop()); -->a -->b --> b
Popping the top int of t which is b and pushing in to s
t.pop(); --> -->a
pops the peek element b
**Comment for any further queries. Upvote if the answer is satisfactory.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.