In C++, which of the following is not a derived container under STL?

2022

In C++, which of the following is not a derived container under STL?

  1. A.

    queue

  2. B.

    deque

  3. C.

    priority queue

  4. D.

    stack

Attempted by 58 students.

Show answer & explanation

Correct answer: B

In C++, STL (Standard Template Library) provides several container types. These are categorized into sequence containers, associative containers, and container adapters. Container adapters are derived from sequence containers and provide restricted interfaces.
A derived container (or container adapter) is one that is built on top of a base container and provides a specific interface. Examples include stack, queue, and priority_queue.
Let's analyze each option:
queue / क्यू: This is a container adapter that follows FIFO (First In, First Out) principle. It is implemented using deque. Since it is built on a base container, it is a derived container.
deque / डी-क्यू: This is a sequence container that allows insertion and deletion at both ends. It is not a container adapter but a base container. Therefore, it is not a derived container.
priority queue / प्रायोरिटी क्यू: This is a container adapter that stores elements with priority. It is implemented using a vector or deque. Since it is built on a base container, it is a derived container.
stack / स्टैक: This is a container adapter that follows LIFO (Last In, First Out) principle. It is implemented using deque. Since it is built on a base container, it is a derived container.
Thus, the only option that is not a derived container is deque.
हिन्दी उत्तर:
C++ में, STL (Standard Template Library) कई कंटेनर प्रकार प्रदान करता है। इन्हें अनुक्रम कंटेनर, संबंधित कंटेनर और कंटेनर एडेप्टर में वर्गीकृत किया जाता है। कंटेनर एडेप्टर अनुक्रम कंटेनर पर आधारित होते हैं और एक विशिष्ट इंटरफेस प्रदान करते हैं।
एक डिराइव्ड कंटेनर (या कंटेनर एडेप्टर) वह होता है जो आधार कंटेनर पर बनाया गया हो और एक विशिष्ट इंटरफेस प्रदान करता हो। उदाहरण के लिए, स्टैक, क्यू और प्रायोरिटी क्यू हैं।
आइए प्रत्येक विकल्प का विश्लेषण करें:
क्यू / queue: यह एक कंटेनर एडेप्टर है जो FIFO (पहला आया, पहला जाए) सिद्धांत का पालन करता है। इसे डी-क्यू का उपयोग करके लागू किया जाता है। चूंकि यह आधार कंटेनर पर बनाया गया है, इसलिए यह एक डिराइव्ड कंटेनर है।
डी-क्यू / deque: यह एक अनुक्रम कंटेनर है जो दोनों छोरों पर डेटा डालने और हटाने की अनुमति देता है। यह कंटेनर एडेप्टर नहीं है बल्कि एक आधार कंटेनर है। इसलिए, यह एक डिराइव्ड कंटेनर नहीं है।
प्रायोरिटी क्यू / priority queue: यह एक कंटेनर एडेप्टर है जो प्राथमिकता के साथ तत्वों को संग्रहीत करता है। इसे वेक्टर या डी-क्यू का उपयोग करके लागू किया जाता है। चूंकि यह आधार कंटेनर पर बनाया गया है, इसलिए यह एक डिराइव्ड कंटेनर है।
स्टैक / stack: यह एक कंटेनर एडेप्टर है जो LIFO (आखिरी आया, पहला जाए) सिद्धांत का पालन करता है। इसे डी-क्यू का उपयोग करके लागू किया जाता है। चूंकि यह आधार कंटेनर पर बनाया गया है, इसलिए यह एक डिराइव्ड कंटेनर है।
इस प्रकार, केवल वह विकल्प जो डिराइव्ड कंटेनर नहीं है वह डी-क्यू है।

Explore the full course: Dsssb Tgt Computer Science Paper 2