If you push 1, then 2, then 3 onto an empty stack, what does the next pop return?
Answer3
Pop removes the top item, which is the last one pushed: 3.
Coding · Facts & stats
7 fact-checked facts about stacks in computing, each with the reason behind it. 5 more are in today's round and join this page after it closes.
Answer3
Pop removes the top item, which is the last one pushed: 3.
AnswerBoth the front end and the back end of an application
Full-stack developers handle the user-facing front end as well as the server-side back end.
AnswerPeek
Peek (sometimes called top) returns the top item while leaving the stack unchanged.
AnswerRecursion that never reaches a stopping case
Each function call adds a frame to the call stack; endless recursion keeps adding frames until space runs out.
AnswerStack underflow
Underflow means removing from an empty stack; overflow means adding beyond its capacity.
AnswerA stack
Numbers are pushed; each operator pops its operands, computes, and pushes the result back.
AnswerA stack
Depth-first search follows one path as deep as possible, which a stack (or recursion) naturally supports.