Practice Flashcards
Flip to reveal answersWhat is a queue?
Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.
All 5 Flashcards — Queues (FIFO)
Sign up free to track progress and get spaced-repetition review schedules.
Question
What is a queue?
Answer
A structure added to at one end and taken from at the other: items join at the back and leave from the front. The first item in is the first out — first in, first out, or FIFO.
Question
What are the four queue operations?
Answer
enqueue adds an item at the back; dequeue removes the item at the front and returns it; front returns the next item out without removing it; isEmpty says whether anyone is waiting.
Question
Why is a plain list a poor implementation of a queue?
Answer
Removing from the front of a list shifts every remaining item down one place, which is O(n) every time. A proper queue structure removes from the front in constant time.
Question
What one question chooses between a stack and a queue?
Answer
Does the most recent item matter most, or the one that has waited longest? Most recent means a stack; longest waiting means a queue.
Question
Give three uses of a queue.
Answer
Print jobs, so they print in the order sent; process scheduling, where round robin takes the front process and returns it to the back; and buffering data such as keystrokes or network packets, which must be handled in arrival order.
Read the notes
Full study notes for Queues (FIFO)
Topic 6.2 hub
Data structures
More from Topic 6.2
All flashcards in this topic
Computer Science exam skills
Paper structures & tips
Track your progress with spaced repetition
Sign up free — Aimnova tells you exactly which cards to review and when, so you remember everything before your IB exam.
Start Free