It is shown in this paper how a solution for a combinatorial problem obtained from applying the greedy algorithm is guaranteed to be optimal for those instances of the problem that, under an appropriate algebraic representation, satisfy the Cohen-Macaulay property known for rings and modules in Commutative Algebra. The choice of representation for the instances of a given combinatorial problem is fundamental for recognizing the Cohen-Macaulay property. Departing from an exposition of the general framework of simplicial complexes and their associated Stanley-Reisner ideals, wherein the Cohen-Macaulay property is formally defined, a review of other equivalent frameworks more suitable for graphs or arithmetical problems will follow. In the cas...