🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.It removes the last element
  2. B.It shifts every remaining element, so each pop is O(n)
  3. C.It is not allowed on lists
  4. 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 →