Greedy Analysis Strategies

2024-01-19 18:38
文章标签 analysis greedy strategies

本文主要是介绍Greedy Analysis Strategies,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Greedy Analysis Strategies

  • Greedy algorithm stays ahead.
    Show that after each step of the greedy algorithm, its solution is at least as good as other algorithm’s.
    Ex.Interval scheduling

  • Structural.
    Discover a simple “structural” bound asserting that every possible solution must have a certain value. Then show that your algorithm always achieves this bound.
    Ex.Interval partitioning

  • Exchange argument
    Gradually transform any solution to the one found by the greedy algorithm without hurting its quality.
    Ex.Minimizing lateness

Remark.
Greedy algorithm do not always give an optimal solution but can produce a solution that is guaranteed to be close to optimal.

Basic Elements of Greedy Algorithm

Usually, if the given problem has the following ingredients(hallmark in other teaching material, Steve add this note), then it is more likely to develop a greedy algorithm for it.

  • Greedy-choice property.
    A locally optimal choice is globally optimal。

We can assemble a globally optimal solution by making locally optimal(greedy) choices. That is, when we make the choice that looks best in the current problem, without considering results from subproblems.

  • Optimal substructure.
    A problem exhibits optimal substructure if an optimal solution to the problem contain within it optimal solutions to subproblems.

注意,这里的最优子结构和动态规划的hallmark 1是一样的。事实上,贪心法解决不了的问题,可以尝试使用动态规划来解决。

在这里插入图片描述
0-1背包问题,有最优子结构,但使用贪心法无法解决,需要使用动态规划。

这篇关于Greedy Analysis Strategies的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/623323

相关文章

Versioned Staged Flow-Sensitive Pointer Analysis

VSFS 1.Introduction2.Approach2.1.相关概念2.2.VSFS 3.Evaluation参考文献 1.Introduction 上一篇blog我介绍了目前flow-sensitive pointer analysis常用的SFS算法。相比IFDS-based方法,SFS显著通过稀疏分析提升了效率,但是其内部依旧有许多冗余计算,留下了很大优化空间。 以

OpenCV_连通区域分析(Connected Component Analysis-Labeling)

申明:本文非笔者原创,原文转载自:http://blog.csdn.net/icvpr/article/details/10259577 OpenCV_连通区域分析(Connected Component Analysis/Labeling) 【摘要】 本文主要介绍在CVPR和图像处理领域中较为常用的一种图像区域(Blob)提取的方法——连通性分析法(连通区域标

Greedy 类型题总结

Jump Game:思路: Greedy:用maxreach来记录每次可以跳到的最大值,如果某个i > maxreach, 表明这个i我们reach不到,return false,否则 一直更新maxreach class Solution {public boolean canJump(int[] nums) {if(nums == null || nums.length == 0) {

MATH36022 Numerical Analysis 2 Approximation of Functions – Week 3 Exercises

Show that the Chebyshev polynomials are orthogonal on ( − 1 , 1 ) (−1, 1) (−1,1) with respect to the weight function ( 1 − x 2 ) − 1 / 2 (1 − x^2)^{−1/2} (1−x2)−1/2. Ans: T n ( x ) = cos ⁡ ( n arcc

《Data Structure Algorithm Analysis in C》Chap.10笔记

5大算法:贪婪 Greedy,分治 Divide and conquer,动态规划 Dynamic Programming,随机 Randomized,回溯 Backtracking。 每一个小节都是一个具体的问题,应当仔细看,待看的:10.2.2-4,10.3,10.4.3,10.5.2。

05.德国博士练习_06_mapping_analysis

文章目录 1. exercise01: mapping multi-fields2. exercise02: nested and join mapping3. exercise03: custom analyzer 1. exercise01: mapping multi-fields # ** EXAM OBJECTIVE: MAPPINGS AND TEXT ANALYS

MATH36022 Numerical Analysis 2 Approximation of Functions – Week 2 Exercises

Attempt these exercises in advance of the tutorial in Week 3 Find the best L ∞ L_\infin L∞​ approximation to f ( x ) = x n + 1 + ∑ k = 0 n a k x k f (x) = x^{n+1} + \sum_{k=0}^na_kx^k f(x)=xn+1+∑k=

ROS naviagtion analysis: costmap_2d--ObstacleLayer

构造函数 ObstacleLayer(){costmap_ = NULL; // this is the unsigned char* member of parent class Costmap2D.这里指明了costmap_指针保存了Obstacle这一层的地图数据} 对于ObstacleLater,首先分析其需要实现的Layer层的方法: virtual void o

ROS naviagtion analysis: costmap_2d--StaticLayer

从UML中能够看到,StaticLayer主要是在实现Layer层要求实现的接口。 virtual void onInitialize();virtual void activate();virtual void deactivate();virtual void reset();virtual void updateBounds(double robot_x, double rob

ROS naviagtion analysis: costmap_2d--CostmapLayer

这个类是为ObstacleLayer StaticLayer voxelLayer 这种维护了自己所在层的地图数据的类,提供了一些公共的操作方法。 从UML中可以看到,这个类提供了以下方法,这些方法的参数列表均为(costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j) updateWit