Background see httpenwikipediaorgwikiSetmathematics In math

Background [see http://en.wikipedia.org/wiki/Set_(mathematics) ]:
In mathematics, a set is a collection of distinct elements (say integer numbers). For example, A={2, 5, 7} and B={3, 5, 8, 10} are two different sets. There are several basic operations for constructing new sets from given two sets, but let\'s just consider three basic ones:

C = union(A,B);
C = intersection(A,B); C = difference(A,B);

---> C = A B={2, 5, 7, 8, 10}
---> C = A B={5}
---> C = A-B = A \\ B ={2, 7} also aka. complement

What to do:
You are asked to develop a set library (using two different representations: array and link list) and then implement a driver program that gets two sets and one of the above operation as a command to apply, then it prints the resulting set...

Developing set library:
For interface, create an interface file set.h which contains boiler plate and the followings:

setADT setNew(); /* create a new empty set */
void setFree(setADT S); /* free the space allocated for the set S */

/* if not successful, return 0; otherwise, return the number of elements in the set (including the element just inserted). Also note that the elements might be given in different orders, but your function should always keep the set in a sorted manner after each insertion */

/* returns a new set containing A B */ setADT setIntersection(setADT A, setADT B);

/* returns a new set containing A B */

/* returns a new set containing A \\ B */

int setCardinality(setADT S); /* return the number of elements in S */ void setPrint(setADT S, char *name); /* print elements of S, A = {2, 5, 7} */

For implementation, you will be asked to have two different implementations: setArrayImp.c and setLinkedListImp.c

1). First implement set library as setArrayImp.c which uses a constant size array to store set elements (suppose max set size is 100).

2). Second implement this library as setLinkedListImp.c which uses a dynamic single linked list to store set elements.

Develop a driver.c program and compile it with two different imp of set library

1. Create two sets called A and B.
2. Ask user to enter positive integers for set A (end input when user enters -1)
3. Ask user to enter positive integers for set B (end input when user enters -1)

4. In a loop
4.1. Ask user to enter a command:
4.2 If Q is entered, quit from this loop.
4.3 If U, I, or D is entered, compute set C as union, intersection, or difference.

setPrint(A, \"A\"); setPrint(A, \"B\"); setPrint(C, \"C\"); print the number of elements in C
setFree(C);

5. free A and B
Compile/execute driver.c with setArrayImp.c as well as setListImp.c

Solution

System.out.println(b.getDifference(set1,set2));

}

}

Background [see http://en.wikipedia.org/wiki/Set_(mathematics) ]: In mathematics, a set is a collection of distinct elements (say integer numbers). For example,
Background [see http://en.wikipedia.org/wiki/Set_(mathematics) ]: In mathematics, a set is a collection of distinct elements (say integer numbers). For example,

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site