【问题标题】:How to take into account the minimum value vertex in Dijsktra algorithm?如何考虑 Dijkstra 算法中的最小值顶点?
【发布时间】:2017-12-28 14:35:08
【问题描述】:

我已阅读这篇文章Understanding Time complexity calculation for Dijkstra Algorithm 以了解 Dijkstra 算法的复杂性。但是,我看不到在每次迭代中选择堆内最小值顶点(在此迭代后将固定其值的顶点)的时间与微积分有关......有人可以清楚地解释我它在哪里参与?

谢谢!

【问题讨论】:

    标签: dijkstra


    【解决方案1】:

    Dijkstra 算法是这样的

    repeat V times:
        take min from heap; // Works in O(1)
        erase min from heap; // Works in O(log V)
        for vertices connected with current:
            update distance; // Works in O(1)
            update value in heap; // Works in O(log V)
    

    第一个循环进行V 迭代,第二个循环对所有顶点迭代的度数求和,所以它是2 * EO(E) 迭代。总复杂度为O(VlogV + ElogV)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-09
      • 1970-01-01
      • 2018-04-08
      • 1970-01-01
      • 2013-04-19
      • 2018-05-23
      • 2022-07-21
      相关资源
      最近更新 更多