var rrankbegin if then for : to - do pick the -th preference of man mif acceptable then record the marriagetry(successor( ))cancel the marriage end end else record the stable set end end try the initial data are represented by two matrices that indicate the men' and women' preferences var wmrarray nn of womanmwrarray nn of man accordinglywmrm denotes the preference list of man mi wmrm, is the woman who occupies the -th rank in the list of man similarlymwrw is the preference list of woman wand mwrw, is her -th choice sample data set is shown in table the result is represented by an array of women xsuch that xm denotes the partner of man in order to maintain symmetry between men and womenan additional array ysuch that yw denotes the partner of woman wvar xyarray of integer table sample input data for wmr and mwr actuallyy is redundantsince it represents information that is already present through the existence of in factthe relations [ [ ]wy[ [ ] hold for all and who are married thusthe value yw could be determined by simple search of xthe array yhoweverclearly improves the efficiency of the algorithm the information represented by and is needed to determine stability of proposed set of marriages since this set is constructed stepwise by marrying individuals and testing stability after each proposed marriagex and are needed even before all their components are defined in order to keep track of defined componentswe may introduce boolean arrays singlemsinglewarray of boolean