Questions: Stack ADT: Array and Linked-List Implementations

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

An array-based stack doubles its capacity when full. A sequence of 1024 pushes is performed starting from capacity 1. Approximately how many total element-copy operations occur across all resize events?

A1024 copies — each push copies one element
BAbout 2048 copies total — each element is copied on average about twice, giving amortized O(1) per push
CAbout 524,288 copies — each resize copies all elements and there are log₂(1024) resizes
DZero copies — modern arrays don't need to copy on resize
Question 2 Multiple Choice

You need a stack for a recursive depth-first search where the maximum depth is unpredictable. Which implementation concern is most relevant?

AAn array stack is preferred because it is cache-friendly and DFS typically reuses recently accessed elements
BA linked-list stack eliminates capacity overflow risk, since each node is individually allocated — important when maximum depth is unknown
CBoth implementations are equivalent since both guarantee O(1) push and pop
DA linked-list stack is always preferred over an array stack for correctness
Question 3 True / False

The stack Abstract Data Type (ADT) defines the behavior — LIFO ordering, push, and pop — independently of how the data is actually stored in memory.

TTrue
FFalse
Question 4 True / False

In a linked-list stack, push is expected to traverse to the end of the list to insert the new element, making it an O(n) operation.

TTrue
FFalse
Question 5 Short Answer

Explain why an array-based stack that doubles its capacity when full achieves amortized O(1) push, even though individual resize operations cost O(n).

Think about your answer, then reveal below.