1,431 views
1 votes
1 votes

Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements.

Now, in this queue what will be condition for FULL and EMPTY?

Full:(REAR+1)%n== FRONT

       (or)

      (FRONT+1)%n==REAR

       (or)

     FRONT==REAR

      

 Empty:   FRONT==REAR

       (or)

              REAR== FRONT

--------------------------------------------------------------------------------------------------

I think FRONT== REAR and REAR==FRONT means same, So, both will give correct result in case of Empty . It is a checking if both pointer pointing same or not. But for FULL it will not give correct result. because, Rear cannot go same location as Front locating . But Front pointer can come and point same location as rear.

So, in case of Full, Rear point array that must be array index more than Front

Am I right?

Then what equation will valid?

 

 

Please log in or register to answer this question.

Related questions

3 votes
3 votes
1 answer
1
hacker16 asked Nov 14, 2017
21,361 views
In circular singly linked list, insertion of node requires modification of how many pointers?1 pointers2 pointers3 pointers 4 pointers
0 votes
0 votes
2 answers
2
0 votes
0 votes
1 answer
3
Lakshman Bhaiya asked Oct 17, 2018
25,562 views
In a linked list with $n$ nodes, the time taken to insert an element after an elementpointed by some pointer is:$(A) O(1)$$(B) O(logn)$$(C) O(n)$$(D) O(nlogn)$