Condition applicable if Queue is non - empty - Data Structure

Q.  Which among the below specified condition is applicable if the Queue is non - empty?
- Published on 19 Oct 15

a. rear > front
b. rear < front
c. rear = front
d. Unpredictable

ANSWER: rear > front


  • Nirja Shah   -Posted on 16 Nov 15
    The value of both front and rear will be -1 when the queue is empty. For insertion the value of rear is incremented by one and the element is inserted at new rear position.
    So if the queue is nonempty then rear > front condition must hold.

Post your comment / Share knowledge

Enter the code shown above:
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)