Drawbacks of linear or simple queue

Drawbacks of linear queue:-

Although linear queue data structure is a useful data structure but it has two drawbacks.
1) If we keep on incrementing front during deletion of element then at the final stage front crosses the upper bound of the array which can be problematic at run time.
2) Even if the space is available, still the linear queue reports. This happens particularly when rear is at last index and front is not at zero'th index and we are trying to insert an element.

Solutions of above problem:-

1) Instead of incrementing front, we can shift every element of the queue one cell downwards that is whenever the deletion is done. we can pull every element in the queue to it's lower index. But this solution is feasible only when queue is small otherwise a lot of processing will have to be done.
2) Implement queue as a 'Circular queue'.

Post a Comment

0 Comments