The AA department has received several applications for teaching assistant positions from its students. The applicants are provided with the list of available courses and asked to submit a list of their preferences. The teacher assistant committee at UNIV prepares a sorted list of the applicants (according to the applicants' background and experience) for each course and the total number of teaching assistants needed for the course.
Note that there are more students than available teaching assistant spots. There can also be multiple teaching assistants per course, though a single teaching assistant can only be assigned to 1 course. Making matters more complicated, certain applicant-course pairings are disallowed since an applicant does not have enough background in a specific course.
We will say that A (an applicant) prefers C (a course) to C' iff C is ranked higher than C' on his/her preference list. The committee wants to apply an algorithm to produce feasible assignments such that each student is assigned to at most one course. The assignment of the teaching assistants to courses is feasible if none of the following situations arises:
1. If an applicant A and a course C are allowed and not matched, but A prefers C more than his/her assigned course, and C prefers A more than, at least, one of the applicants assigned to it.
2. If an applicant, A, and a course, C, are allowed such that A is unmatched, and C has an empty spot or an applicant A' assigned to it such that C prefers A to A'.
You need to solve these problems:
1. Modify the Gale-Shapley algorithm to find a feasible assignment for the teaching assistants-courses matching problem. Write pseudo code of modified algorithm.
2. Prove that the modified algorithm produces feasible teaching assistants-courses assignments.