Computer Science I / Stacks and Queues
Practice question · Select all that apply

Select every statement the lesson supports about stacks and queues.

Hints
  1. Four statements come straight from the lesson; one describes a different ADT entirely.
  2. Ask what a queue uses to decide who is served next: importance, or arrival time?
Show the answer
  • A. When well implemented, push, pop, enqueue and dequeue are all O(1)
  • B. A deque generalises both a stack and a queue
  • D. peek returns the top of a stack without removing it
  • E. Both are ADTs and can be built on an array or on a linked list
Why

Stacks and queues are interfaces with constant-time operations under either implementation, peek looks without removing, and a deque relaxes both restrictions. Serving by priority is the priority queue, a different ADT, expecting a queue to know about importance is a common and expensive mix-up.

Read the lesson: Stacks and Queues →

Practise Stacks and Queues

The app has 7 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Stacks and Queues