In mathematics, economics, and computer science, the stable marriage problem (also stable matching problem or SMP) is the problem of finding a stable matching between two equally sized sets of elements given an ordering of preferences for each element. A matching is a mapping from the elements of one set to the elements of the other set. A matching is stable whenever it is not the case that both the following conditions hold.In other words, a matching is stable when there does not exist any match (A, B) by which both A and B are individually better off than they would be with the element to which they are currently matched. Another way to phrase this outcome, from Economics, is to say that the set exhibits Pareto Efficiency.The stable marriage problem has been stated as follows:Note that the requirement that the marriages be heterosexual distinguishes this problem from the stable roommates problem. https://en.wikipedia.org/wiki/Stable_marriage_pr...