Question: 1. [25 points Write a Python function that takes an instance of the Stable Matching problerm and a perfect matching of the men and women,

1. [25 points Write a Python function that takes an instance of the Stable Matching problerm and a perfect matching of the men and women, and returns a list of all rogue couples with respect to that matching. The function should have the form rogue_couples (n, man_pref, woman_pref, wife) where man pref and woman pref contain the preference lists (as in our implementation of the Propose-and-Reject algorithm) and wife is a list that describes the perfect matching (wife[m] is the index of man m's wife). It should return the list of all rogue couples as (man woman) tuples, in any order. Your function must run in time O(n2), and the code must include comments explaining the data structures you create and justifying the running time bound. For example, running it with man pref - woman_pref[[3, 2, 1, o], wife = [3, 2, 0, 1] should return [(1, 1), (2, 1), (3, 0), (3, 3)] (possibly in a different order), since this is the solution to problem la on homework 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
