In the deque implementation, using singly linked list, what would be the time…

2023

In the deque implementation, using singly linked list, what would be the time complexity of deleting an element from the rear end?

  1. A.

    O(1)

  2. B.

    O(N log N)

  3. C.

    O(N)

  4. D.

    More than one of the above

  5. E.

    None of the above

Attempted by 575 students.

Show answer & explanation

Correct answer: C

In a deque implemented using a singly linked list, each node contains a data field and a pointer to the next node. Since there is no backward pointer, accessing the rear end requires traversing the entire list from the head to reach the second-to-last node.

To delete the element at the rear end, the second-to-last node's next pointer must be updated to null. This requires visiting all nodes in the list, resulting in a time complexity of O(N).

Option A (O(1)) is incorrect because it assumes direct access to the rear, which is not possible without a tail pointer. Option B (O(N log N)) is incorrect as it applies to algorithms with divide-and-conquer logic, not linear traversal. Option D is incorrect because only one option is correct. Option E is incorrect because O(N) is a valid complexity.

हिन्दी उत्तर: सिंगली लिंक्ड लिस्ट का उपयोग करके डेक को लागू करने में, प्रत्येक नोड में डेटा फील्ड और अगले नोड के लिए पॉइंटर होता है। चूँकि कोई बैकवर्ड पॉइंटर नहीं होता है, इसलिए रियर एंड तक पहुँचने के लिए पूरी सूची को हेड से ट्रैवर्स करना पड़ता है।

रियर एंड पर तत्व को हटाने के लिए, दूसरे-से-अंतिम नोड के नेक्स्ट पॉइंटर को नल करना होता है। इसके लिए सभी नोड्स को ट्रैवर्स करना पड़ता है, जिससे समय जटिलता O(N) होती है।

विकल्प A (O(1)) गलत है क्योंकि यह रियर तक प्रत्यक्ष पहुँच की धारणा करता है, जो टेल पॉइंटर के बिना संभव नहीं है। विकल्प B (O(N log N)) गलत है क्योंकि यह विभाजन-और-शासन तर्क वाले एल्गोरिदम के लिए लागू होता है, न कि रैखिक ट्रैवर्सल के लिए। विकल्प D गलत है क्योंकि केवल एक विकल्प सही है। विकल्प E गलत है क्योंकि O(N) इस ऑपरेशन के लिए एक मान्य जटिलता है।

Explore the full course: Up Lt Grade Assistant Teacher 2025