In Python, which data structure is used to implement a queue?
Correct answer
A. List
19 views
A. List
19 views
Among the built-in types listed, a list is used to implement a queue: add with append() and remove from the front with pop(0).
Because pop(0) is slow on long lists, collections.deque is the recommended choice in real code, and the queue module offers thread-safe queues — but neither is a basic built-in data structure.
Keep preparing with more Computer Science MCQs on MCQsExam.com.
Not sure why the answer is A? Ask here and get an explanation.