简体   繁体   English

Prim算法的最坏情况图

[英]Worst-Case Graph for Prim's Algorithm

My Algorithms class is talking about Prim's Algorithm as a method of finding Minimum Spanning Trees of weighted graphs. 我的算法课谈论的是Prim算法,它是一种找到加权图的最小生成树的方法。 Our professor asked us to try to think of an example of a graph that Prim's Algorithm takes N^2 time to solve (N = number of Vertices). 我们的教授要求我们尝试考虑一个图的示例,该图的基本算法需要N ^ 2的时间来解决(N =顶点数)。 No one in the class could think of one off the top of their head, so I'm asking you. 班上没人能想到一个人,所以我问你。 I'm pretty sure Prim's Algorithm = O(N^2), so this would be the worst-case scenario for the algorithm. 我很确定Prim的算法= O(N ^ 2),所以这将是该算法最坏的情况。

What's a good example of a graph that takes N^2 time for Prim's Algorithm to solve? 有什么很好的示例图需要花费N ^ 2的时间来求解Prim的算法?

If I understand your question correctly, the example is trivial. 如果我正确理解了您的问题,那么这个例子很简单。

If the graph is complete, there're O(N^2) edges, so just reading the graph is O(N^2) . 如果图是完整的,则有O(N^2)边,因此仅读取图就是O(N^2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 什么是斯坦因算法的最坏情况输入? - What is the Worst-Case Input for Stein's Algorithm? 确定算法的最坏情况复杂度 - Determining the worst-case complexity of an algorithm 礼物交换算法(Jarvis 算法)计算凸包的最坏情况是什么? - What is the worst-case for gift-wapping algorithm (Jarvis’s Algorithm) to compute convex hull? 找到最坏的情况 - find the worst-case 在Kruskal的算法中使用union-find是否会影响最坏情况的运行时? - Does using union-find in Kruskal's algorithm actually affect worst-case runtime? 哪种排序算法可提供最佳的最坏情况性能? - What sort algorithm provides the best worst-case performance? 这种算法的最坏情况时间复杂度是多少? - What is the worst-case time-complexity of this algorithm? 递归算法的最坏情况下运行时间复杂度的计算 - Calculating worst-case run time complexity of recursive algorithm 最坏情况时间复杂度为O(n)的算法总是比最坏情况时间复杂度为O(n ^ 2)的算法快吗? - Is an algorithm with a worst-case time complexity of O(n) always faster than an algorithm with a worst-case time complexity of O(n^2)? 触发Douglas-Peucker算法的Worst-Case的线? - Line that triggers Worst-Case for Douglas-Peucker Algorithm?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM