Why longest path problem doesn't have optimal substructure?
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?的更多相关文章
- 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 ...
- Eclipse 项目红色叹号:Build Path Problem
Description Resource Path Location TypeA cycle was detected in the build path of project 'shgl-categ ...
- 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 ...
- 干货 | 列生成VRPTW子问题ESPPRC( Elementary shortest path problem with resource constraints)介绍附C++代码
00 前言 各位小伙伴大家好,相信大家已经看过前面column generation求解vehicle routing problems的过程详解.该问题中,子问题主要是找到一条reduced cos ...
- 以计算斐波那契数列为例说说动态规划算法(Dynamic Programming Algorithm Overlapping subproblems Optimal substructure Memoization Tabulation)
动态规划(Dynamic Programming)是求解决策过程(decision process)最优化的数学方法.它的名字和动态没有关系,是Richard Bellman为了唬人而取的. 动态规划 ...
- Dynamic Programming | Set 2 (Optimal Substructure Property)
正如我们在 Dynamic Programming | Set 1 (Overlapping Subproblems Property) 中讨论的那样,当一个问题具有以下2种性质时,建议使用动态规划来 ...
- [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 ...
- poj3764 The XOR Longest Path【dfs】【Trie树】
The xor-longest Path Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10038 Accepted: ...
- 【CF edu 27 G. Shortest Path Problem?】
time limit per test 3 seconds memory limit per test 512 megabytes input standard input output standa ...
随机推荐
- Android_Intent_passObject
方法4. 把基本的数据类型封装到一个对象中,然后通过intent传递该对象需要考虑对Person对象进行序列化 MainActivity: package com.example.day06_acti ...
- thinkphp中关于rbac的两个session
最近在做单点登录,需要session由sso的client生成.所以研究了下RBAC的类的代码. 有了这两个seesion就可以用rbac进行权限验证 $_SESSION[C('ADMIN_AUTH_ ...
- 四种方式写按钮点击事件和Android 中常用的布局
1.匿名内部类的方式 2.创建一个类实现onClickListener,实现onClick方法,设置控件点击时传一个类的对象 3.让当前类实现onClickListener,设置控件点击事件时传递一个 ...
- 在masterpage中添加对usercontrol的引用
在masterpage中添加对usercontrol的引用的方式: <%@ Register Src="/_controltemplates/15/Excellent Employee ...
- 学习笔记7_Java_day11_JSP原理(5)
4. jsp原理(理解) * jsp其实是一种特殊的Servlet > 当jsp页面第一次被访问时,服务器会把jsp编译成java文件(这个java其实是一个servlet类) > 然后再 ...
- Java之反射的应用
package com.zheges; import java.util.Date; public class Customer {//JavaBean 对象 private String nam ...
- OC - 12.NSURLRequest与NSURLConnection
##NSURLRequest NSURLRequest封装了一次网络请求所需要的数据,主要封装了以下信息: 请求路径(URL) 请求方法(GET或POST) 请求头 请求体 超时参数 NSURLReq ...
- O-C相关-06:对象与对象的关系
对象与对象的关系 1.对象与对象的关系 依赖 关联 组合 常常讨论对象与对象关系时会提供两个属于:内聚性,耦合性 内聚一般指功能上的指向性 耦合一般指关联上的依赖性 2.依赖: 对象之间最弱的一种关联 ...
- 初步认识 Web Service
Web Service初步认识 Web Service:不是框架,不是一种技术,而是一种跨平台,跨语言的规范. 作用:异构平台之间的交互,解决了不同平台,不同语言所编写的应用之间的相互调用.(远 ...
- 利用php获取图片完整Exif信息类 获取图片详细完整信息类
<?php /** * @Author: TonyLevid * @Copyright: TonyLevid.com * @Name: Image Exif Class * @Version: ...