Question: This is the code for Gale - Shapley algorithm which handle cases where the number of men and women are unequal. for this input case

This is the code for Gale-Shapley algorithm which handle cases where the number of men and women are unequal.
for this input case
43
m1 w1 w2 w3
m2 w1 w3 w2
m3 w2 w1 w3
m4 w3 w1 w2
w1 m1 m2 m3 m4
w2 m3 m4 m1 m2
w3 m2 m1 m4 m3
output not coming properly.
output came:
m1 w1
m3 w2
m4 w3
expected output:
m1 w1
m2 w3
m3 w2
please correct the logic of the algorithm.
Also provide psuedo code, time complexity and space complexity.
I want correct output for all test cases and here my code is failing so make sure it does not fail other test cases.
 This is the code for Gale-Shapley algorithm which handle cases where

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!