ITPEC FE Morning October 2019 Question 6
ITPEC FE Morning October 2019 — Question 6 of 80
Stack operations — trace PUSH/POP sequence to find final stack state.
Execute operations on an initially empty stack:
- •
PUSH 1→[1] - •
PUSH 5→[1, 5] - •
POP→ removes5→[1] - •
PUSH 7→[1, 7] - •
PUSH 6→[1, 7, 6] - •
PUSH 4→[1, 7, 6, 4] - •
POP→ removes4→[1, 7, 6] - •
POP→ removes6→[1, 7] - •
PUSH 3→[1, 7, 3]
Final stack (top to bottom): 3, 7, 1 → (c)
Why not others:
- (a) 1, 7, 3 — wrong order (bottom-to-top instead of top-to-bottom)
- (b) 3, 4, 6 — implies 4 and 6 were never popped
- (d) 6, 4, 3 — implies 6 and 4 remained after the two POPs
Key rule: Stack is LIFO — POP always removes the most recently pushed element.
AI-generated — may contain errors
The original exam layout is preserved in the image so diagrams, formulas, tables, and code remain accurate.
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.