Adoption

We are going to focus on the full problem for now. We’ll briefly discuss the subtask afterwards.

Start with special cases of the problem. Suppose we have a minimal case, where n = 1.

  1. Suppose Alice and Bob are the only two people applying for one cat and one dog. How would you determine who gets which pet?

Now, apply this to larger inputs.

  1. Can you extend the criterion from the previous question, to decide who gets which pet in larger test cases?
  2. Design an algorithm which determines who gets which pet.
  3. Write a program which implements your algorithm.

For an extension, we’ll think about the intended solution for the subtask. Note that you need some material from future lectures to solve the following problem.

  1. Suppose you didn’t make the observations in the previous questions. Rather than determining who gets which pet by a clever rule, propose an algorithm which exhausts the possible allocations of pets without repeated work.