When is it a bad idea to use a heap for a Priority Queue?
问题 In the section that explains Dijkstra's Algorithm in the book Introduction to Algorithms by Cormen et. al., while analysing the complexity of the algorithm, they say If the graph is sufficiently sparse ... we can improve the algorithm by implementing the min priority queue with a binary min heap So I was wondering, what is the need for such a statement? Isn't it always wiser to just use heaps for priority queues? 回答1: There are many different ways to implement a priority queue. A binary min