Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the ADT Set ( in Java ) using array data structure as specified. The following additional operations are to be defined in the SetInterface:

Implement the ADT Set (in Java) using array data structure as specified.
The following additional operations are to be defined in the SetInterface:
1. equals(SetInterface rhs): returns true if both sets contain the same elements. A.equals(B)
2. union(SetInterface rhs): if A, B, C are sets, has the form C = A.union(B). Union returns a set that
contains all the elements in set A and B, but only lists duplicates once.
3. intersect(SetInterface rhs): if A, B, C are sets, has the form C = A.intersect(B). intersect returns
a set of all objects that are members of both the sets A and B.
4. SetInterface must extends Iterable.
5. toString(): returns a string that indicates an object's state. An object's state is the data that is
currently stored in the object's fields. Format: {a,b,c}{}{1}
Remember from your CS1300 that the empty set is a set, and the empty set is a subset of every set. If A={1,2,3} B={2,3,4} then C=A.intersect(B) is C={2,3}
1. You must implement the generic ArraySet class.
2. Your generic SetInterface must be documented for Javadoc.
3. You must include a SetTest with a main to test your Set ADT. Remember that when you test
equals and intersection, test each method with at least the following five cases:
Case 1: A and B are equal but distinct sets, for example, A ={1,2,3}, B={2,1,3}
Case 2: A and B are such that they have different sizes, but one is a subset of the other, for example, A ={1}, B ={1,2}
Case 3: A and B are non-empty and different in size but have common elements, for example, A={1,2,3}, B ={2,3,4,5}
Case 4: they are non-empty with nothing in common, for example, A ={1}, B={2,3}, and
Case 5: one is non-empty and the other empty.
4. You need to make sure that you have thoroughly tested every method of your set class. For the test program, you must hard-code all the special cases. There will be NO input to this program.
There should be 3 Java source and the report files:
SetInterface.java ArraySet.java SetTest.java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 1 Lnai 9851

Authors: Paolo Frasconi ,Niels Landwehr ,Giuseppe Manco ,Jilles Vreeken

1st Edition

3319461273, 978-3319461274

More Books

Students also viewed these Databases questions

Question

Identify Freuds developmental stages.

Answered: 1 week ago