Stable matching problem: Difference between revisions

Content deleted Content added
Line 20:
'''function''' stableMatching {
Initialize all ''m'' <math>\in</math> M and ''w'' <math>\in</math> W to ''free''
'''while''' <math>\exists</math> ''free'' man ''m'' who still has a woman ''w'' to propose to {
''w'' = ''m''&rsquo;s highest ranked such woman
'''if''' ''w'' is ''free''
(''m'', ''w'') become ''engaged''
'''else''' some pair (''m&rsquo;'', ''w'') already exists
'''if''' ''w'' prefers ''m'' to ''m&rsquo;''
(''m'', ''w'') become ''engaged''
''m&rsquo;'' becomes ''free''
'''else'''
(''m&rsquo;'', ''w'') remain ''engaged''
}
}