Skip to main content

Back to the full dot-point answer

SingaporeComputer ScienceQuick questions

Data Structures

Quick questions on Stacks and queues explained: H2 Computing

6short Q&A pairs drawn directly from our worked dot-point answer. For full context and worked exam questions, read the parent dot-point page.

What are stacks?
Show answer
A stack allows access only at one end, the top. The most recently added item is the first removed:
What are queues?
Show answer
A queue adds at the rear and removes from the front, like people in a line:
What are circular buffers for array queues?
Show answer
In a fixed-size array, dequeuing from the front would leave a gap, and shifting everything forward is O(n)O(n). A circular buffer instead advances front and rear indices that wrap around the array end, so both operations stay O(1)O(1) with no shifting.
What is q1?
Show answer
A stack has push(1), push(2), push(3), pop() applied. What is returned and what is on top afterward? [2 marks]
What is q2?
Show answer
Define stack overflow. [1 mark]
What is q3?
Show answer
Why is a queue, not a stack, used for breadth-first search? [2 marks]

Have a question we have not covered?

This dot-point answer is short enough that we have not extracted many short questions yet. Read the full dot-point answer or ask Mo, our study assistant, in the chat for follow ups.

All Computer ScienceQ&A pages