3

The question is pretty simple. I need to prove that there's no greedy algorithm that can obtain the optimal solution for a given problem.

It is unclear to me if there is any condition that a problem must meet so that exists a certain greedy algorithm to obtain the optimal solution. Or if there is any sufficient condition for the problem not to be solvable by a greedy algorithm.

I am precisely talking about the greedy coloring:

http://en.wikipedia.org/wiki/Greedy_coloring

D1X
  • 5,025
  • 5
  • 21
  • 36
  • 5
    Might be wrong (thus not an answer), I don't believe you can prove there is no greedy algorithm, because that is going to depend on the greedy property. For graph coloring however, you can prove there is no KNOWN greedy algorithm, since the problem is NP-Complete, and greedy algorithms are running in polynomial time, chosing one element at a time. – amit Apr 30 '15 at 16:20
  • Agree. And I think what you really want to know is how to prove that a specific greed algorithm does not obtain an optimal solution always. I'm not even sure if greediness has a formal definition. – Juan Lopes Apr 30 '15 at 16:37
  • I guess that the definition of greediness is *always trying to choose the locally/currently best option*. Greedy algorithms maybe as optimal as these non-greedy sometimes, but usually they aren't. – Mateusz Piotrowski Apr 30 '15 at 16:42
  • Well FWIW a counter example works for the knapsack problem, but I'm unsure about graph coloring. This question talks about providing a specific counterexample of a scenario where it won't give you the optimal solution, http://stackoverflow.com/questions/12023731/graph-coloring-and-np-completeness – matrixanomaly Apr 30 '15 at 16:49
  • In my experience, greedy algorithms are useful when good performance is preferable to a high quality result. Greedy algorithms do (usually) less operations (usually during the search phase) and return a result which may not be optimal. I don't know if that is provable though. – Gentian Kasa Apr 30 '15 at 17:12

2 Answers2

3

I need to prove that there's no greedy algorithm that can obtain the optimal solution for a given problem.

Well, that's going to depend on the definition of the property you chose.

Have a look for example on the graph coloring problem, and assume you have an oracle M that given a partially colored graph, returns true if and only if there is a graph coloring for it.

Now, using this oracle, a greedy algorithm can be as follows:

for each vertex v:
   for each color c:
        temporarly color v with c
        run M on partially colored graph
        if M yields true, make c constant to v, and abort the inner loop

The above algorithm is coloring the graph in a greedy manner, chosing one vertex at a time, according to the answer of the oracle M. (Choosing the best answer of M and assigning it to each vertex and color, where set of answers is false or true)

Does it feel like cheating? Probably, because there is no known such M that runs in polynomial time, but if you run an exponential algorithm that creates M, there is definetly a greedy algorithm for it.

You can however prove that there is no KNOWN algorithm that greedily chooses in polynomial time (or any other polynomial algorithm for that matter) that yields an optimal answer for graph coloring, since graph coloring is NP-Complete, and we don't know any algorithm that solves NPC problems efficiently (and most believe such does not exist).

However, if at some point we will prove P=NP, we can efficiently calculate M, and we will get an efficient greedy algorithm that solves graph coloring.

amit
  • 175,853
  • 27
  • 231
  • 333
1

Greedy, on a philosophical level is the phenomenon, when the holder of the attribute thinks on short-term and ignores long-term incomes. As we can see, this is not a well-defined concept. How is the algorithm greedy? If we do not know the essence of its greedyness, then we do not have the means to prove that it does not obtain the optimal solution. Also, the concept of obtaining the optimal solution is ambiguous. It might mean that it will never obtain the optimal solution, or it might mean that there is at least a case when it cannot obtain the optimal solution. I suggest documenting the issue, understanding the problem and then starting to think how to prove this again.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175