Content deleted Content added
→top: namesakes |
→Algorithm: MOS:ALGO |
||
Line 32:
==Algorithm==
'''
Initialize all ''m'' ∈ M and ''w'' ∈ W to ''free''
'''while''' ∃ ''free'' man ''m'' who still has a woman w to propose to
w = first woman on m's list to whom m has not yet proposed
'''if''' w is ''free'' '''then'''
(m, w) become ''engaged''
'''else''' some pair (m', w) already exists
'''if''' w prefers m to m' '''then'''
m' becomes ''free''
(m, w) become ''engaged''
'''else'''
(m', w) remain ''engaged''
'''end if'''
'''end if'''
'''repeat'''
==Optimality of the solution==
|