Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions