Why does Dijkstra's Algorithm use a heap (priority queue)?

后端 未结 4 682
余生分开走
余生分开走 2021-02-07 05:33

I have tried using Djikstra\'s Algorithm on a cyclic weighted graph without using a priority queue (heap) and it worked.

Wikipedia states that the original implementatio

4条回答
  •  深忆病人
    2021-02-07 05:59

    For sparse graph, if implement with binary min heap runtime is(E*logV), however if you implement it with Fibonacci heap, runtime would be(VlogV+E).

提交回复
热议问题