← Quiz: Queues and Deques: all 13 questions
Quiz: Queues and Deques · Question 2 of 13
Why should you not use list.pop(0) as a queue in Python?
Why should you not use list.pop(0) as a queue in Python?
- A.It removes the last element
- B.It shifts every remaining element, so each pop is O(n)
- C.It is not allowed on lists
- D.It returns None
Answer & explanation
Correct answer: It shifts every remaining element, so each pop is O(n)
deque.popleft() removes from the front in O(1).
Can you get the rest right without peeking?
Take the timed Quiz: Queues and Deques quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →