Reputation: 123
can anyone tell me an easy way to implement a priority queue that only offers extract_min, add, and reduce key without using the build-in one in Java. It is better to be as efficient as possible and not hard to implement. Please give me a sample. Thank you in advance!
Upvotes: 0
Views: 940
Reputation: 525
It's rather conceptual problem than implementational one, so I suggest you to have a look at wiki Priority queue or heap pages or dive into some really great books, for instance "Introduction to algorithms". When you understand logic behind those data structures (and other algorithms as well) implementing them in any programming language shouldn't be a big deal.
Upvotes: 4