MAX - 1 should be value of rear (end) if queue is full - Data Structure

Q.  What should be the value of rear (end) if the queue is full (elements are completely occupied )?
- Published on 19 Oct 15

a. 1
b. - 1
c. MAX + 1
d. MAX - 1
e. zero (null)

ANSWER: MAX - 1
 

    Discussion

  • Nirja Shah   -Posted on 16 Nov 15
    When we insert the item in the queue, first we have to check that queue should not be full. For checking this condition we have to set that
    if(rear==MAX-1)
      {
        cout<< "queue is Full";
      }
    Here MAX is the size of queue.

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.)