贪心算法——普林姆算法(Greedy Algorithm-Prim’s Algorithm)
贪心算法简介(Introduction of Greedy Algorithm)
(pic: https://www.sicas.cn/Students/Info/Content_110622143056742.shtml)
There is a common situation in which a cashier changes money for customers. Suppose the cashier has paper money denominations 100, 50, 20, 10, 5, 1, 0.5, 0.1 yuan, and we need to change 250 yuan for customers using the smallest number of paper money. How does the cashier make change?
Generally, we want to use as many 100 paper money as we can, then we consider smaller denomination which as 50, 20, 10 and so on until get 250. The priority denomination sequence is 100, 50, 20, 10, 5, 0.5, 0.1. For this scenario, 250= 2*100+50.
The strategy used by the cashier to change is to make decision based on what is the locally best choice.
We h

本文介绍了贪心算法中的普林姆算法,用于寻找加权图的最小生成树。通过每次选择与当前子树连接的边中成本最小的节点,逐步构建最小成本的树。算法的时间复杂度为O(|E|log|V|),适用于解决实际问题。
最低0.47元/天 解锁文章

1493

被折叠的 条评论
为什么被折叠?



