Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
O(|E| + |V| log |V|)
我知道愚蠢的问题,但是如果有日志,它是线性的吗?
不,O(VlogV) =/= O(V) 因为 VlogV 与 V 的比率发散到无穷大
“如果有日志是线性的”这个问题的答案是否定的。线性通常指 O(N)
这意味着它取决于图,并且可以通过同时考虑边和顶点来更精确地测量复杂性。更简单的界限是O(V^2)因为在最坏的情况下|E|=O(V^2)因此O(|V^2| + |V| log |V|) = O(V^2)。在最好的情况下|E| = 0,所以O(|V| log |V|),所以运行时间从来不是真正的线性。
O(V^2)
|E|
O(|V^2| + |V| log |V|) = O(V^2)
|E| = 0
O(|V| log |V|)