queue no-count approach

Queue No-count approach and Implementation

If you check our previous article Queue Example with count approach, the field nElements in MyQueue class imposes slight overhead on the insert() and remove() methods as these methods increments and decrements this variable.

When you deal with huge number of insertion and deletion operations, it might affect the performance. That’s why some Queues will be implemented without an element count variable in the program.

In the following example Queue, no-count approach, you can rely on front and rear fields to check whether the queue is full or empty or to check how many items or elements are there in the queue.

Example: Queue no-count approach

Output

Recommended Posts

References

Leave a Reply

avatar
  Subscribe  
Notify of