Skip to content
← All questions

Why can the San Francisco to San Diego route be split at Los Angeles?

The San Francisco to San Diego route can be split at Los Angeles because the problem exhibits optimal substructure. Once the shortest SF→LA and LA→SD segments are known, they combine to give the shortest SF→SD route. The equation SHORTESTPATH(SF,SD)=SHORTESTPATH(SF,LA)+SHORTESTPATH(LA,SD)SHORTEST_PATH(SF, SD) = SHORTEST_PATH(SF, LA) + SHORTEST_PATH(LA, SD) makes this explicit.

Conditions

  • The example assumes the overall route passes through Los Angeles.
  • The narrator states that finding the shortest subroutes guarantees the overall shortest route in this example.

Reasoning, step by step

  1. Identify the intermediate city LA.
  2. Solve SF→LA and LA→SD separately.
  3. Combine the two optimal subresults to obtain the global optimum.

Example

The video uses a map route from San Francisco to San Diego via Los Angeles to illustrate optimal substructure.

Common misconceptions

  • Assuming that any route can be split arbitrarily without considering optimal substructure.
  • Confusing optimal substructure with overlapping subproblems.

Watch the explanation

Explore next

Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.