Does 'Priority Queue' data structure fits to SET Theory?
-
28-05-2021 - |
Question
Does the Priority Queue data structure follow the set theory in terms of the uniqueness of its elements in its content?
I mean you cannot put a duplicate of an entity in the priority queue. -whereas you can put many duplicates of same value in a queue:
Queue<int> q = new Queue<int>();
q.Enqueue(5);
q.Enqueue(5);
q.Enqueue(3);
Can yo confirm if this is correct or incorrect, please? Thanks
Solution
Depends on the implementation, but most priority queues that I've seen allow duplicate keys/priorities. Note that if a priority queue enforces unique keys, that probably means that priorities, not values, will be unique.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow