In this tutorial, you will learn
1. Linked List Based Implementation of queues.
2. Learn the basic concept of priority queues.
What is the linked list based implementation of queues?
- class Queue
- linked_list l;
- bool isEmpty()
- return (l.isEmpty());
- void enQueue (int value)
- int deQueue()
- cout<<"\nQueue is Empty\t";
- return 0;
- int x=l.start()->info;
- return x;
What is a priority queue?
A priority queue is a data structure like a normal queue but it has one additional feature which is that data is also given priority. The data of higher priority is served first. The question arises when 2 or more items have same priority. Actually, there is no specific rule for this. There are different approaches for that. Mostly, it is treated as a queue which means that the element coming first will be served first. But coders design their approach.
The idea of priority queues makes perfect sense. E.g. if someone is designing a management system for a hospital, he must take into account the emergencies. If there is a patient who must be treated immediately, he must be given higher priority. Similarly, in an office receiving many complaints, the complaints must be arranged with priority. E.g. in a cereal industry, there are two complaints. The extruder (used for cooking and cutting) needs to be repaired and the lights in an office need to be replaced, the extruder complaint must be dealt with earlier because the industry actually earns through this. Thus, priority queues find their uses in many different areas of coding. And if used properly, they can be used as a strong tool to make code more efficient.
NOTE: In next tutorial, priority queues will be ended and I would try to wrap up the course of Data Structures in some more lectures. Do go through codes of queues to understand their usage and implementation properly.
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.