Priority Queue


The next project on my list is once again a graduate school project. I am expanding the stack and queue by adding in a priority queue feature. This functionality helps expand the program into one that is much more useful.

The basic stack and queue works much like a Pez dispenser. The user is able to store information one number at a time in the queue. This stack of numbers is then stored in either the system memory or a database. The user can then recall each number one at a time. If the queue is set up using a first in, first out structure, the user will get back numbers in the order that they put them in. If the queue is set up using a last in, first out structure, the user will get back the last number they entered and the rest of the numbers in that reverse order.

To make the queue more useful, I have now added in a priority feature. This gives the user control over the order of the objects in the queue. Each queue item is now assigned a priority number. The higher the number of priority, the more important the item is. This allows the user to rank items in their list. The ranking feature allows the program to be more applicable to large scale projects. However, this feature does take a toll on resources. If a queue becomes very large, it would run better using a database call. Storing large queues directly in memory can create performance issues that would need to be avoided.

View the Priority Queue C++ Project on GitHub 

Share this story:

Tags: programming, data structures, cpp, c++, priority queue