Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Are all queues, priority queues? If not, what is the difference?

Just beginning my journey of learning data structures and algorithms, and I’m getting hung up on the fact that there is information everywhere about this kind of stuff with different nicknames for each data structure. But in layman’s terms are all queues in fact priority queues, the priority bit being exactly what makes them so special?

I tried googling are all queues priority queues and I got recommended to stack overflow’s massive hive mind of information.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The answer is both Yes and No. They are the same theoretical concept, but are implemented with completely unrelated data structures.

A generic priority queue requires a somewhat complex "heap" sort of data structure. However, a insertion-order-queue can use a totally unrelated "list-like" data structure, which is far faster. So while they are the same general concept, they usually use totally unrelated data structures.

You see this in other places too. In layman’s term, a "list" is a general concept. But C++ calls this concept "SequenceContainer", and then very confusingly named their SequenceContainer linked list data structure std::list. But in layman’s terms, std::vector and std::deque and std::array are also lists, despite being totally unrelated data structures.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading