arrow
arrow
arrow
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,
Question



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

Correct option is A


In a circular queue, an empty condition is typically represented by both front and rear being -1.
Important Key Points:
1. Empty Condition for Circular Queue:
· Initially, when the queue is empty, both front and rear are set to -1.
· Condition:
if (front == -1 && rear == -1)
cout << "Queue is empty";
Knowledge Booster:
· In Circular Queues, insertion happens at the rear, and deletion happens at the front.
· Circular queues efficiently utilize memory by reusing empty spaces at the beginning of the array.
· The condition (rear + 1) % MAX_SIZE == front is used to check for a full queue in circular queue implementations.
· (b) Front = rear = 0 → ❌ Incorrect
· This condition does not necessarily indicate an empty queue.
· If front = rear = 0, it may contain one element.
· (c) Front = rear + 1 → ❌ Incorrect
· This condition is used for a full queue, not an empty one.
· The queue is full when:
if ((rear + 1) % MAX_SIZE == front)
cout << "Queue is full";

Free Tests

Free
Must Attempt

UPTET Paper 2 Social Science : PYP Held on 23rd Jan 2022 (Shift 2)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
Free
Must Attempt

UPTET : Paper 1 Full Mock - 01

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
Free
Must Attempt

UPTET : Paper 2 Maths & Science Full Mock - 01

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
test-prime-package

Access ‘BPSC TRE (11-12)’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
383k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow