贪心算法——普林姆算法(Greedy Algorithm-Prim's Algorithm)

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

贪心算法——普林姆算法(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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值