Suppose a circular queue of capacity (n – 1) elements is implemented with an…

2021

Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the Insertion and deletion operations are carried out using REAR and FRONT as array index variables respectively. Initially, REAR=FRONT=0. The conditions to detect queue full and queue empty are:

Answer: A. full:(REAR+1) mod n ==FRONT empty:REAR ==FRONTIn a circular queue implemented with an array of n elements and capacity of (n-1), one position is kept empty to distinguish between full and empty states.…

  1. A.

    full:(REAR+1) mod n ==FRONT

    empty:REAR ==FRONT

  2. B.

    full:(REAR+1) mod n==FRONT

    empty:(FRONT+1) mod n==REAR

  3. C.

    full:REAR==FRONT

    empty:(REAR+1) mod n==FRONT

  4. D.

    full:(FRONT+1) mod n==REAR

    empty:REAR==FRONT

  5. E.

    Question not attempted

Attempted by 498 students.

Show answer & explanation

Correct answer: A

In a circular queue implemented with an array of n elements and capacity of (n-1), one position is kept empty to distinguish between full and empty states.

Queue is empty when REAR == FRONT, as both pointers point to the same position with no elements.

Queue is full when (REAR + 1) mod n == FRONT, because the next insertion would overwrite the front element, indicating the queue is full.

This ensures that the queue can hold at most (n-1) elements, and the empty and full conditions are unambiguous.

हिन्दी उत्तर:

एक गोलाकार क्यू को n तत्वों के एक एरे के साथ लागू किया जाता है और क्षमता (n-1) होती है, तो खाली और पूर्ण अवस्थाओं को अलग करने के लिए एक स्थान खाली रखा जाता है।

क्यू खाली होता है जब REAR == FRONT होता है, क्योंकि दोनों पॉइंटर एक ही स्थान को इंगित करते हैं और कोई तत्व नहीं होता है।

क्यू पूर्ण होता है जब (REAR + 1) mod n == FRONT होता है, क्योंकि अगले डेटा का इन्सर्ट करना फ्रंट तत्व को ओवरराइट कर देगा, जिसका अर्थ है कि क्यू पूर्ण है।

इससे यह सुनिश्चित होता है कि क्यू में अधिकतम (n-1) तत्व हो सकते हैं, और खाली और पूर्ण अवस्थाएँ अस्पष्ट नहीं होती हैं।

Explore the full course: Bpsc

Loading lesson…