← Stack & Queue Quiz: all 8 questions
Stack & Queue Quiz · Question 8 of 8
Which Python structure should you use as a queue?
Which Python structure should you use as a queue?
- A.list with pop(0)
- B.collections.deque with popleft()
- C.set
- D.dict
Answer & explanation
Correct answer: collections.deque with popleft()
list.pop(0) shifts every element (O(n)); deque.popleft() is O(1).
Can you get the rest right without peeking?
Take the timed Stack & Queue Quiz quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →