Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 1 : (rear + 1) % n == front

Advertisement

Detailed Solution

सही उत्तर (rear + 1) % n == front है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

For a circular queue of capacity n with front and rear indices, the queue is full when / क्षमता n वाली वृत्ताकार कतार में front और rear सूचकांकों के साथ, कतार पूर्ण होती है जब

1.
(rear + 1) % n == front
2.
rear == front
3.
rear == n - 1
4.
front == 0 and rear == n - 1

Correct Answer: (rear + 1) % n == front

One slot is sacrificed to distinguish full from empty: the queue is full when the next position after rear wraps around to front, i.e. (rear + 1) % n == front. The condition rear == front denotes an empty queue. / पूर्ण और खाली में अंतर के लिए एक स्लॉट छोड़ा जाता है: कतार तब पूर्ण होती है जब rear के बाद की स्थिति front पर आ जाए, अर्थात् (rear + 1) % n == front। rear == front खाली कतार को दर्शाता है।

Downloaded from PrepSnap (prepsnap.in)