If circular queue is implemented using array having size MAX_SIZE in which…
2023
If circular queue is implemented using array having size MAX_SIZE in which array index starts with 0, front points to the first element in the queue, and rear points to the last element in the queue. Which one of the following conditions is used to specify that the circular queue is empty?
- A.
Front = rear = –1
- B.
Front = rear = 0
- C.
Front = rear + 1
- D.
More than one of the above
- E.
None of the above
Attempted by 557 students.
Show answer & explanation
Correct answer: A
In a circular queue implemented using an array of size MAX_SIZE with indices starting from 0, the queue is considered empty when both front and rear pointers are set to –1. This initialization indicates that no elements are present in the queue. When the queue is empty, no element can be dequeued, and the first insertion will set both front and rear to 0. The condition Front = rear = –1 is a standard way to represent an empty queue in such implementations.
हिन्दी उत्तर: यदि सर्कुलर क्यू को MAX_SIZE आकार के ऐरे से लागू किया गया है जिसमें इंडेक्स 0 से शुरू होता है, तो क्यू खाली होता है जब front और rear दोनों –1 पर होते हैं। यह इनिशियलाइज़ेशन इंगित करता है कि कोई भी तत्व क्यू में नहीं है। जब क्यू खाली होता है, तो कोई तत्व निकाला नहीं जा सकता है, और पहली डिन्क्यू ऑपरेशन दोनों front और rear को 0 पर सेट करेगी। Front = rear = –1 की शर्त ऐसे इम्प्लीमेंटेशन में खाली क्यू को दर्शाने का एक मानक तरीका है।