Which data structure is used for efficient searching, insertion, and deletion…
2024
Which data structure is used for efficient searching, insertion, and deletion of elements?
- A.
Stack
- B.
Queue
- C.
Hash Table
- D.
More than one of the above
- E.
None of the above
Attempted by 702 students.
Show answer & explanation
Correct answer: C
To determine which data structure supports efficient searching, insertion, and deletion, we analyze each option:
1. Stack: Follows LIFO (Last In, First Out) principle. Insertion and deletion occur only at the top. It does not support efficient searching or deletion from arbitrary positions. Hence, it is not suitable for all three operations.
2. Queue: Follows FIFO (First In, First Out) principle. Insertion at rear and deletion at front. It does not allow efficient searching or deletion from arbitrary positions. Thus, it is not ideal for all three operations.
3. Hash Table: Uses a hash function to map keys to indices. Provides average O(1) time complexity for search, insert, and delete operations. Supports efficient access regardless of data size. Therefore, it is suitable for all three operations.
4. More than one of the above: This option is incorrect because only hash table supports all three operations efficiently. Stack and queue do not.
5. None of the above: This is incorrect because hash table meets the criteria.
हिन्दी उत्तर:
तत्वों की कुशल खोज, प्रविष्टि और विलोपन के लिए डेटा संरचना का चयन करने के लिए, हम प्रत्येक विकल्प का विश्लेषण करते हैं:
1. स्टैक: LIFO (लास्ट इन, फर्स्ट आउट) सिद्धांत का पालन करता है। डेटा का इन्सर्शन और डिलीशन केवल शीर्ष पर होता है। यह किसी भी स्थान पर खोज या डिलीशन के लिए कुशल नहीं है। इसलिए, यह तीनों ऑपरेशनों के लिए उपयुक्त नहीं है।
2. क्यू: FIFO (फर्स्ट इन, फर्स्ट आउट) सिद्धांत का पालन करता है। डेटा का इन्सर्शन पीछे से और डिलीशन आगे से होता है। यह किसी भी स्थान पर खोज या डिलीशन के लिए कुशल नहीं है। इसलिए, यह तीनों ऑपरेशनों के लिए उपयुक्त नहीं है।
3. हैश टेबल: एक हैश फंक्शन का उपयोग करके कीवर्ड को इंडेक्स में मैप करता है। खोज, इन्सर्शन और डिलीशन ऑपरेशन के लिए औसत O(1) समय जटिलता प्रदान करता है। डेटा की आकृति के आधार पर कुशल पहुंच प्रदान करता है। इसलिए, यह तीनों ऑपरेशनों के लिए उपयुक्त है।
4. उपरोक्त में से एक से अधिक: यह विकल्प गलत है क्योंकि केवल हैश टेबल तीनों ऑपरेशनों को कुशलता से समर्थित करता है। स्टैक और क्यू नहीं।
5. उपरोक्त में से कोई नहीं: यह गलत है क्योंकि हैश टेबल आवश्यकताओं को पूरा करता है।