In the second phase, the following operations are executed on the stack. push where; top; push know; push ledge; pop; pop; push knowledge; top; push is; push tree; pop; push free; push where; push thy; pop; top; push the; push world; top; top; push have; pop; push has; push not; top; push being; pop; push been; push broken; top; push up; push into; top; push fragments; top; push by; push narrow; push domestic; top; push walls; Henceforth, we continue executing only the operation pop as before, until the stack is empty. What will be the output of these final pop operations only? (Please ignore all outputs until the final sequence of pop operations. In your answer, please exclude all spaces, quotation marks or any additional character other than the words from the stack.)
A stack allows three operations - push, pop and top. Operation push puts the input element at the top of the stack. Operation pop takes the top element out of the stack and returns it to the caller. Operation top only returns the top element of the stack without deleting it from the top of the stack.
Consider an initially empty stack of English words. Let us consider the following operations (separated by semicolons) on the stack.
top; push where; top; push the; push mind; top; push has; pop; push is; top; push without; push dear; pop; push fear; top; push and; push the; top; push bed; pop; top; push head; top; push is; push held; push high;
From this point on, we continue executing only the operation pop on the stack, until the stack is empty. The output of these pop operations only is as follows.
highheldisheadtheandfearwithoutismindthewhere
Note that there is no space on either side of the words printed by the pop operation. This ends the first phase of operations on the stack.
In the second phase, the following operations are executed on the stack.
push where; top; push know; push ledge; pop; pop; push knowledge; top; push is; push tree; pop; push free; push where; push thy; pop; top; push the; push world; top; top; push have; pop; push has; push not; top; push being; pop; push been; push broken; top; push up; push into; top; push fragments; top; push by; push narrow; push domestic; top; push walls;
Henceforth, we continue executing only the operation pop as before, until the stack is empty. What will be the output of these final pop operations only?
(Please ignore all outputs until the final sequence of pop operations. In your answer, please exclude all spaces, quotation marks or any additional character other than the words from the stack.)
Step by step
Solved in 2 steps with 1 images