The learning goals of this lab are the following:
In this lab, you are asked to implement the one method in the SetsPractice
class. The removeX
method takes a set of sets and a string x
and returns a new set of sets where every occurrence of x
has been removed from the sets. This is a warm up method to the more complex methods you will implement next week.
In addition, there are some pencil and paper problems to get you thinking recursively in preparation for next week’s lab.
Warm up with removeX
This method is a warm up problem that will help you catch some common mental bugs around how java objects work. In Java, a Set
of objects is really a set of references to objects. When you have finished this method, be sure to upload to gradescope and check the results of the tests provided there before going on.
Test your work In the main
method, you should call your method on various examples to verify that it works correctly.
Pencil & paper exercises Answer the questions below (see “Thinking Recursively”).
Teaming up You may work with a partner. Larger groups are not permitted.
Working with a partner, answer these questions. Check your answers with a TA or professor before the end of lab.
Your answer to the last question provides a hint on how you might implement power set generation using recursion (think of $P_T$ as the result of a recursive call on a smaller input).