In C++ Standard Library terminology, which of the following is a sequence…
2022
In C++ Standard Library terminology, which of the following is a sequence container rather than a container adaptor?
Answer: B. deque — ConceptThe C++ Standard Library distinguishes containers, which store elements themselves, from container adaptors, which expose a restricted interface over…
- A.
queue - B.
deque - C.
priority_queue - D.
stack
Attempted by 218 students.
Show answer & explanation
Correct answer: B
Concept
The C++ Standard Library distinguishes containers, which store elements themselves, from container adaptors, which expose a restricted interface over an underlying container. The term “adaptor” describes this wrapper interface; it does not require C++ class inheritance.
Application
queue is a container adaptor with FIFO access; its default underlying container is deque.
deque is a sequence container that stores its own elements, supports random access, and permits insertion or removal at both ends.
priority_queue is a container adaptor whose default underlying container is vector and whose interface maintains heap ordering.
stack is a container adaptor with LIFO access; its default underlying container is deque.
Cross-check
The standard container taxonomy lists deque among sequence containers, while stack, queue, and priority_queue are container adaptors. Therefore, deque is the sequence container and is the intended answer.