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. 【iOS程序启动与运转】- RunLoop个人小结

    学习iOS开发一般都是从UI开始的,从只知道从IB拖控件,到知道怎么在方法里写代码,然后会显示什么样的视图,产生什么样的事件,等等.其实程序从启动开始,一直都是按照苹果封装好的代码运行着,暴露的一些属 ...

  2. jQuery免费资料

     JQvery免豆.pdf       jQuery实战之仿flash跳动的按钮效果[源码]http://down.51cto.com/data/188600JQuery 1.4.2 手册简体中文版h ...

  3. start mysqld on Mac server

    #!/bin/sh # Source the common setup functions for startup scripts test -r /etc/rc.common || exit 1 . ...

  4. Linux下如何在打开终端的时候自动配置相关环境

    参考博客“Linux启动文件.设置环境变量的位置”(http://www.2cto.com/os/201305/208251.html) 在不可取的root权限的时候可以选择编辑~/.bashrc文件 ...

  5. 在iframe中获取父页面的元素

    a.html <!DOCTYPE html> <html> <head> <title></title> </head> < ...

  6. Python之路【第二十二篇】:Django之Model操作

    Django之Model操作   一.字段 AutoField(Field) - int自增列,必须填入参数 primary_key=True BigAutoField(AutoField) - bi ...

  7. CSS3 动画效果合集

    @charset "UTF-8"; /*! * animate.css -http://daneden.me/animate * Version - 3.5.1 * License ...

  8. Unity3D 关于运动模型

    首先,要让一个物体在3D世界里面运动起来. 要在一个具有碰撞器的面和一个具有碰撞器的体. 要具有碰撞器属性,不然其他物体会穿过的. 默认的碰撞器是一个具有阻碍效果的,如果让碰撞器具有了一个触发器属性I ...

  9. [转] c# 数据类型占用的字节数

    http://www.cnblogs.com/laozuan/archive/2012/04/24/2467888.html

  10. win10 Administrator

    和Win7/Win8.1一样,Win10的管理员账户Administrator是默认隐藏和关闭的,因为该账户权限极高,被不法分子利用后存在极大风险.但如果你想在某些特殊情况下使用该账户,就需要手动将其 ...