Help


from Wikipedia
« »  
Consider finding a shortest path for travelling between two cities by car, as illustrated in Figure 1.
Such an example is likely to exhibit optimal substructure.
That is, if the shortest route from Seattle to Los Angeles passes through Portland and then Sacramento, then the shortest route from Portland to Los Angeles must pass through Sacramento too.
That is, the problem of how to get from Portland to Los Angeles is nested inside the problem of how to get from Seattle to Los Angeles.
( The wavy lines in the graph represent solutions to the subproblems.

1.818 seconds.