Monday, 26 September 2011

Disadvantages of Queues



Disadvantages of Queues
 
 we can not insert a new value at left hand side empty locations, we can insert only on right side, but we cant insert at right side. so memory is wasted.
To overcome this program use Circular Queues



 1. Initially empty Queue is there so,f = 0 and r = -1

 
2. When we add 5 elements to queue, the state of the queue becomes as follows with f = 0 and r = 4

3. Now suppose we delete 2 elements from Queue then, the state of the Queue becomes as follows, with f = 2 and r = 4

4. Now, actually we have deleted 2 elements from queue so, there should be space for another 2 elements in the queue, but as rear pointer is pointing at last position and Queue overflow(condition is full) condition
(r == size-1) is true, we can’t insert new element in the queue even if it has an empty space.
To overcome this problem there is another variation of queue called CIRCULAR QUEUE.



Queues:

No comments:

Post a Comment