
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Quiz #1B
Name:
READ THE QUESTIONS CAREFULLY!!! DO NOT WASTE TIME DOING MORE THAN IS ASKED FOR. DO NOT IMPLEMENT METHODS UNLESS SPECI- FICIALLY REQUESTED. YOU DO NOT NEED TO COMMENT THE CODE.
Three a essors: ontains returns true if a sp e i ed ob je t is found in the set; returns false otherwise. isEmpty, tests if the Set is empty; and size returns the numb er of elements urrently stored in the Set ontainer. Two mutators: One makes the Set empty; the other (add) inserts a new item.
(a) Implement a zero parameter onstru tor; your implementation may assume the existen e of a one-parameter onstru tor that takes a Comparator as a parameter. Make sure you provide the lass de laration for the default omparator that you will need. (b) Implement ontains. In your implementation, you should use a sequential sear h. If you nd an item in the array that is larger than the item b eing sear h for, you should immediately return false.