hamburger menu
All Coursesall course arrow
adda247
reward-icon
adda247
    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

    MPTET Varg 3 PRT Mock 01

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

    MPTET Varg 3 PRT CDP Subject Test 01

    languageIcon English
    • pdpQsnIcon20 Questions
    • pdpsheetsIcon20 Marks
    • timerIcon20 Mins
    languageIcon English
    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
    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
    383k+ students have already unlocked exclusive benefits with Test Prime!
    Our Plans
    Monthsup-arrow