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.
如果使用 BFS 实现 Kruskal 算法来检查是否添加一条边并创建一个循环,那么该算法的整体 Big-O 运行时间是多少?
会的O(V * E + E * log E)。每个 BFS 都需要O(V)时间,因为树中有V - 1边(如果树还没有完全构建,则更少)并且它针对每个边运行(V是顶点数,E是边数)。所以O(V * E)总的来说。E * log E术语来自对边缘进行排序。
O(V * E + E * log E)
O(V)
V - 1
V
E
O(V * E)
E * log E