When should I use a TreeMap over a PriorityQueue and vice versa?

后端 未结 8 2178
南旧
南旧 2020-12-23 11:46

Seems they both let you retrieve the minimum, which is what I need for Prim\'s algorithm, and force me to remove and reinsert a key to update its value. Is there any advanta

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 12:10

    It depends on how you implement you Priority Queue. According to Cormen's book 2nd ed the fastest result is with a Fibonacci Heap.

提交回复
热议问题