Question

Consider the following sequence of stack operations: PUSH(10) → PUSH(20) → PUSH(30) → POP() → PUSH(40) → POP() → POP() What is the final state of the stack and what were the values returned by the three POP operations?

A Stack contains [10, 20]; POP returned 30, 40, 20 in that order
B Stack contains [10, 40]; POP returned 30, 20, 10 in that order
C Stack contains [10, 20]; POP returned 10, 20, 30 in that order
D Stack is empty; POP returned 40, 30, 20 in that order
E Stack contains [10]; POP returned 30, 40, 20 in that order
Practice Next

Relevant for Exams:

Hey! Ask a query