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.

最新文章

  1. java中的对象,类。与 方法的重载。
  2. 如何使用.NET开发全版本支持的Outlook插件产品(一)——准备工作
  3. 为什么说Babel将推动JavaScript的发展
  4. TortoiseGit 添加ssh key
  5. Xcode模拟器和真机生成的日志查看(转载)
  6. Centos环境下部署游戏服务器-SSH
  7. web版扫雷小游戏(一)
  8. poj 2492A Bug's Life
  9. 开启Apache mod_rewrite模块(解决404 Not Found)
  10. php基础之三 数组
  11. Windows 下 pip和easy_install 的安装与使用
  12. Oracle数据库中直方图对执行计划的影响
  13. 五分钟学习React(四):什么是JSX
  14. 谈谈.NET架构师面试及如何设计面试题
  15. 4月23日 MySQL学习-DDL
  16. web机试
  17. overflow标签
  18. lucene查询索引之Query子类查询——(七)
  19. hashlib和hmac
  20. Angular 4.0 环境搭建

热门文章

  1. launchMode使用详解
  2. 一种协程的 C/C++ 实现
  3. JAVA锁的可重入性
  4. Scala应用函数
  5. linux-ssh远程后台执行脚本-放置后台执行问题(转)
  6. 九度 1371 最小的K个数
  7. bubble_sort
  8. day-5
  9. dynamic关键字
  10. ios NSAssert趣谈