already married becausewere anyone of them still singlem would have picked her beforehand the described process can be formulated by simple linear searchs denotes stability :- :truerepeat inc( )if then pw :wmr[ , ]if ~single[pwthen :rwm[pw,mrwm[pwy[pw]end end until ( ror ~ hunting for trouble source we must investigate all candidates pm who are preferred by to their current assignation mi all preferred men pm mwrw, such that rwmw, in analogy to tracing trouble source comparison between ranks rmwpm, and rmwpm, [pmis necessary we must be carefulhoweverto omit comparisons involving xpm where pm is still single the necessary safeguard is test pm msince we know that all men preceding are already married the complete algorithm is shown below table specifies the nine computed stable solutions from input data wmr and mwr given in table procedure write(adens _marriages *(*global writer *var mmanrmrwintegerbegin rm : rw : for : to - do texts writeint(wx[ ] )rm :rmw[mx[ ]rmrw :rwm[ [ ]mrw endtexts writeint(wrm )texts writeint(wrw )texts writeln(wend writeprocedure stable (mwrinteger)booleanvar pmpwrankilimintegersbooleanbegin :- :truerepeat inc( )if then pw :wmr[ , ]if ~single[pwthen :rwm[pw,mrwm[pwy[pw]end end until ( ror ~si :- lim :rwm[ , ]repeat inc( )if lim then pm :mwr[ , ]if pm rmw[pmx[pm]end end until ( limor ~