当前位置:网站首页>贪心
贪心
2022-07-27 17:10:00 【遨游的菜鸡】
1. 序言
所谓贪心算法是指,在对问题求解时,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,它所做出的仅仅是在某种意义上的局部最优解。
贪心算法没有固定的算法框架,算法设计的关键是贪心策略的选择。必须注意的是,贪心算法不是对所有问题都能得到整体最优解,选择的贪心策略必须具备无后效性(即某个状态以后的过程不会影响以前的状态,只与当前状态有关。)
所以,对所采用的贪心策略一定要仔细分析其是否满足无后效性。
证明每次的局部最优解必须在全局最优解序列中,否则不可能到达全局最优!一般判断贪心是否能取得最优解是通过几个实际数据进行判断。
2.例题
1.跳跃游戏
https://leetcode-cn.com/problems/jump-game/
2.跳跃游戏II
https://leetcode-cn.com/problems/jump-game-ii/
3.加油站
https://leetcode-cn.com/problems/gas-station/
4.分发糖果
https://leetcode-cn.com/problems/candy/
边栏推荐
- Complex number proof of solvability of regular 17 sided ruler and gauge drawing
- Embedded C language structure
- C language: 13. Pointer and memory
- 【深度学习基础知识 - 50】PCA降维 主成成分分析
- Flink introduction and operation architecture
- Embedded C language pointer alias
- DNSSEC verification with dig [verify DNSSEC with dig]
- Adhering to the integration of software and hardware, one Hengke makes efforts to the intelligent educational robot market
- Pytorch reports CUDA error: no kernel image is available for execution on the device error
- Uncover the mystery of Qualcomm ultrasonic fingerprint being "cracked by film"
猜你喜欢

JVM概述和内存管理(未完待续)
Dry goods of technical practice | preliminary exploration of large-scale gbdt training

ToggleButton(按钮开关)

【深度学习基础知识 - 45】机器学习中常用的距离计算方法

一种比读写锁更快的锁,还不赶紧认识一下

Make your chat bubbles colorful

GestureDetector(手势识别)

【深度学习基础知识 - 42】逻辑回归详解

Introduction to socke programming

High cost, difficult to implement, slow to take effect, what about open source security?
随机推荐
GestureOverlayView(手势识别2)
[basic knowledge of deep learning - 42] detailed explanation of logistic regression
IIS 发生未知FastCGI错误:0x80070005
【深度学习基础知识 - 49】Kmeans
IEC104 规约详细解读(二)交互流程以及协议解析
IEC104 规约详细解读(一) 协议结构
Binary search tree
Publish your own NPM component library
MySQL time zone problem
What's new in helix QAC 2022.2, the ace code static testing tool (1)
【深度学习基础知识 - 38】L1正则化和L2正则化的区别
Virtualbox:ssh connection
访问控制
S32k series chips -- Introduction
The valuation exceeds 15.6 billion yuan! Huaqin communication completed the round B financing of 1billion yuan! Qualcomm venture capital, Intel Capital led investment
GestureDetector(手势识别)
ArrayAdapter(数组适配器)与SimpleAdapter(简单适配器)
发布自己的npm组件库
Debian recaptured the "debian.community" domain name, but it's still not good to stop and rest
下放三星3J1传感器:代码暗示Pixel 7人脸识别安全性将大增