arrow
arrow
arrow
Which of the following conditions correctly check the underflow condition in a queue?
Question

Which of the following conditions correctly check the underflow condition in a queue?

A.

front = -1

B.

rear = 1

C.

rear = size

D.

front = size

Correct option is A

An underflow condition in a queue occurs when we try to delete an element from an empty queue.

In a standard implementation of a queue (especially in linear arrays), a common way to check whether the queue is empty is to test if front == -1. This value signifies that no elements are present in the queue yet or all elements have been removed.

Important Key Points:

  1. Underflow occurs when deletion is attempted on an empty queue.
  2. The condition front = -1 is typically used to represent an empty queue.
  3. Once the first element is inserted, front is usually set to 0. Resetting it to -1 indicates queue has become empty again.

Knowledge Booster:

  • rear = 1: This indicates the rear index is at position 1, which is not a reliable indicator of underflow; the queue may still contain elements.
  • rear = size: This condition relates to overflow, not underflow. It means the rear pointer has reached the end of the array.
  • front = size: If front equals size, it typically means the pointer has gone out of bounds or all elements have been dequeued in a circular queue; still not a direct check for underflow in standard linear queue.

Free Tests

Free
Must Attempt

UP SI 2025 Full Mock Test : 01

languageIcon English
  • pdpQsnIcon160 Questions
  • pdpsheetsIcon400 Marks
  • timerIcon120 Mins
languageIcon English
Free
Must Attempt

UP Police Constable Full Mock Test 01

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon300 Marks
  • timerIcon120 Mins
languageIcon English
Free
Must Attempt

Government Policies and Scheme

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon5 Mins
languageIcon English
test-prime-package

Access ‘UPSSSC’ Mock Tests with

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