We all know that the shortest path problem has optimal substructure. The reasoning is like below:

Supppose we have a path p from node u to v, another node t lies on path p: u->t->v ("->" means a path).

We claim that u->t is also a shortest path from u to t, and t->v is a shortest path from t to v.

Proof: if there is another path from u to t that is shorter than u->t, we can simply replace u->t with this shorter path in the solution of u->v, resulting in a shorter path than u->v, contradicting the fact that u->v is a shortest path from u to v.

But why can't we apply similar reasoning to the longest path problem? It's because in the longest path problem there are some constraints imposed on the solution. Suppose u->v is a longest path from u->v, node t lies on it.

So it's like u->t->v. If there is a longer path from u to t than u->t, if we cut off u->t from u->v and paste in the longer path, this new solution may fail some of the restrictions, for example, it may contains a cycle, which is invalid.

Why longest path problem doesn't have optimal substructure?的更多相关文章

  1. Solve Longest Path Problem in linear time

    We know that the longest path problem for general case belongs to the NP-hard category, so there is ...

  2. Eclipse 项目红色叹号:Build Path Problem

    Description Resource Path Location TypeA cycle was detected in the build path of project 'shgl-categ ...

  3. Codefroces Educational Round 27 845G Shortest Path Problem?

    Shortest Path Problem? You are given an undirected graph with weighted edges. The length of some pat ...

  4. 干货 | 列生成VRPTW子问题ESPPRC( Elementary shortest path problem with resource constraints)介绍附C++代码

    00 前言 各位小伙伴大家好,相信大家已经看过前面column generation求解vehicle routing problems的过程详解.该问题中,子问题主要是找到一条reduced cos ...

  5. 以计算斐波那契数列为例说说动态规划算法(Dynamic Programming Algorithm Overlapping subproblems Optimal substructure Memoization Tabulation)

    动态规划(Dynamic Programming)是求解决策过程(decision process)最优化的数学方法.它的名字和动态没有关系,是Richard Bellman为了唬人而取的. 动态规划 ...

  6. Dynamic Programming | Set 2 (Optimal Substructure Property)

    正如我们在 Dynamic Programming | Set 1 (Overlapping Subproblems Property) 中讨论的那样,当一个问题具有以下2种性质时,建议使用动态规划来 ...

  7. [BFS,A*,k短路径] 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛 path (Problem - 6705)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=6705 path Time Limit: 2000/2000 MS (Java/Others)    Mem ...

  8. poj3764 The XOR Longest Path【dfs】【Trie树】

    The xor-longest Path Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10038   Accepted:  ...

  9. 【CF edu 27 G. Shortest Path Problem?】

    time limit per test 3 seconds memory limit per test 512 megabytes input standard input output standa ...

随机推荐

  1. JSTL-core核心代码标签库中的if,set,out等的功能

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...

  2. Java基础知识强化之IO流笔记46:IO流练习之 把文本文件中数据存储到集合中的案例

    1.  把文本文件中数据存储到集合中      需求:从文本文件中读取数据(每一行为一个字符串数据)到集合中,并遍历集合. 分析:      通过题目的意思我们可以知道如下的一些内容,      数据 ...

  3. Linux环境下搭建Android开发环境

    最近在折腾linux.因为咱是搞安卓开发的,所以少不了需要搭建Android开发环境,就此小记,希望能给向我一样的开发者一点帮助!开干! 1.安装JDK 下载JDK包,得到的是类似于jdk-8u65- ...

  4. iOS之NSNotificationCenter通知中心使用事项

    其实这里的通知和之前说到的KVO功能很想,也是用于监听操作的,但是和KVO不同的是,KVO只用来监听属性值的变化,这个发送监听的操作是系统控制的,我们控制不了,我们只能控制监听操作,类似于Androi ...

  5. Mac系统Safari浏览器启动无图模式

    有的时候我们用热点上网,图片的出现会消耗大量的流量,这时候就需要启动无图模式不加载图片. 步骤:启动Safari浏览器->偏好设置->高级->勾选“在菜单栏中显示“开发”菜单”-&g ...

  6. 隐藏/显示&nbsp;我的电脑盘符驱动…

    组策略里更改即可:点击"开始"→"运行",输入"gpedit.msc",打开组策略.在窗口左侧的"本地计算机策略"中依次 ...

  7. iframe父子窗口取值

    父窗口中操作iframe:window.frames["iframeChild"].document //假如iframe的id为iframeChild 在子窗口中操作父窗口:wi ...

  8. eclipse和android studio导入工程的错误

    eclipse中导入工程,需要注意导入的工程是什么,android 工程和java工程是有区别的.如果导入错误了,调起来也比较麻烦.因为入口错了呀. 特别在android studio工程,从其它人的 ...

  9. SQL Server 2012 数据库各个版本功能对比

    作为这篇SQL SERVER 2008数据库各版本功能对比 的姊妹篇,就写点SQL Server 2012 各个版本的区别以及物理以及逻辑上的限制. 个部分来分http://technet.micro ...

  10. ubuntu安装mariadb

    参考网址:https://downloads.mariadb.org/mariadb/repositories/ 以ubuntu12.04安装mariadb10为例.具体其他的可以参考给出的参考网址H ...