big o - What is the overall Big O run time of Kruskal’s algorithm if BFS was used to check whether adding an edge creates a cycle? -
if kruskal's algorithm implemented using bfs check whether adding edge create cycle, overall big-o run time of algorithm be?
it o(v * e + e * log e). each bfs takes o(v) time because there v - 1 edges in tree(or less if tree not build yet) , run each edge(v number of vertices, e number of edges). o(v * e) in total. e * log e term comes sorting edges.
Comments
Post a Comment