The Big O on the Dijkstra Fibonacci-heap solution

后端 未结 2 720
生来不讨喜
生来不讨喜 2021-02-03 13:48

From Wikipedia: O(|E| + |V| log|V|)

From Big O Cheat List: O((|V| + |E|) log |V|)

I consider there is a difference between E + V

2条回答
  •  逝去的感伤
    2021-02-03 14:25

    Dijkstra's is O(|E| + |V| log|V|) with Fibonacci heap and O((|V| + |E|) log |V|) without it.

    Both correct in some way. Big O Cheat List showing the most common implementation and Wiki the best there is.

    O(|E| + |V| log|V|) isn't in O(|V| log|V|) btw. E is in O(|V|^2), not O(|V| log|V|).

提交回复
热议问题