Content deleted Content added
Undid revision 1285865773 by 87.214.42.62 (talk) |
|||
(8 intermediate revisions by 7 users not shown) | |||
Line 1:
{{Short description|Property of a computational problem}}
[[Image:Shortest path optimal substructure.svg|200px|thumb|'''Figure 1'''. Finding the shortest path using optimal substructure. Numbers represent the length of the path; straight lines indicate single [[Edge (graph theory)|edges]], wavy lines indicate shortest [[Path (graph theory)|paths]], i.e., there might be other vertices that are not shown here.]]
In [[computer science]], a problem is said to have '''optimal substructure''' if an optimal solution can be constructed from optimal solutions of its subproblems. This property is used to determine the usefulness of
Typically, a [[greedy algorithm]] is used to solve a problem with optimal substructure if it can be proven by induction that this is optimal at each step.<ref name=cormen /> Otherwise, provided the problem exhibits [[overlapping
<!-- A special case of optimal substructure is the case where a subproblem S<sub>ab</sub> has an activity P<sub>y</sub>, then it should contain optimal solutions to subproblems S<sub>ay</sub> and S<sub>yb</sub>. --> <!-- *TODO: Add Recursion, misc. -->
Line 8 ⟶ 9:
==Example==
Consider finding a [[Shortest path problem|shortest path]] for
As an example of a problem that is unlikely to exhibit optimal substructure, consider the problem of finding the cheapest airline ticket from Buenos Aires to Moscow. Even if that ticket involves stops in Miami and then London, we can't conclude that the cheapest ticket from Miami to Moscow stops in London, because the price at which an airline sells a multi-flight trip is usually not the sum of the prices at which it would sell the individual flights in the trip.
==Definition==
A slightly more formal definition of optimal substructure can be given. Let a "problem" be a collection of "alternatives", and let each alternative have an associated cost, ''c''(''a
== Problems with optimal substructure ==
Line 25 ⟶ 26:
* [[Longest path problem]]
* [[Addition-chain exponentiation]]
* ''Least-cost airline fare.''
== See also ==
* [[Dynamic Programming]]
* [[Principle of optimality]]
* [[Divide and conquer algorithm]]
== References ==
|