How can you be sure that the problem shows the “Greedy Choice Property”?

I’m afraid that there may be a situation in which the “ greedy choice property ” may not be fulfilled,

For any problem, I can only check small data sets. What if a property fails for large data sets?

Can we always be sure?

+4
source share
1 answer

Probably a more theoretical way is to prove that your problem has a Matroid structure. If you can prove that your problem has such a structure, there is a greedy algorithm to solve it.

According to the classic book Introduction to Algorithms, matroid a is an ordered pair M = (S, l) with:

* S is a finite nonemtpy set * l is a nonempty family of subsets of S, such that B element of l and A a subset of B than also A is element of l. l is called the independent subsets of S. * If A and B are elements of l and A is a smaller cardinality than B, then there is some element x that is in B, but not in A, so that A extended by x is also element of l. That is called exchange property. 

Often there is also a weight function w, which assigns a weight to each element x in S.

If you can formulate your function as a weighted matroid, then the following pseudo-code, like Python, solves your problem:

 GREEDY(M,w): (S,l) = M a = {} sort S into monotonically decreasing order by weight w for x in S: if A + {x} in l: A = A + {x} 
+5
source

All Articles