CS21B Introduction to Computing II
Data Structures Quiz
1. Consider the following stack, display the output of the following code and draw the contents of the stack after execution: ( 5 pts )
<--- TOP | push(8) pop() push(7) push(1) push(3) pop() |
|
3 | ||
9 |
2. Consider the following queue, display the output of the following code and draw the contents of the queue after execution: ( 10 pts )
|
enqueue(5) dequeue() dequeue() dequeue() enqueue(6) enqueue(2) |
enqueue(3) enqueue(2) dequeue() enqueue(9) enqueue(7) enqueue(1) |
|
3 | |||
9 |
3. In one or two sentences, what is the single most important advantage of a linked list implementation of a stack/queue over an array-based implementation? ( 5 pts )