CS 240: Algorithms and Data Structures
James Madison University, Fall 2024

Practicing with Collections

Your goal in this lab is to complete the unfinished methods in CollectionExercises.java. For each method, you should first take a minute to think about the problem in order to select an appropriate collection type (or types) to use in your solution. The following JavaDocs may be helpful:

You should take full advantage of the functionality provided by the collection classes to make your solutions as concise and efficient as possible. For example, the Collection interface provides an addAll method that makes it possible to add all of the elements of one collection to another collection with a single instruction. Where appropriate, you should use that method rather than creating a loop that repeatedly calls the add method.

Your solutions for these exercises must satisfy the following requirements:

Submitting

You will submit your completed file through Gradescope. Your file must be in the labs.collections package. You may submit as many times as you like.

Here are the test file that will be used by Gradescope: CollectionExercisesTest.java. Feel free to execute the tests locally to save time.