Lloyd Jefferson wrote:
> I need some help/advice on solving this problem
>
Interesting homework problem. But are you sure your instructor does not
read the email posted to this list?
> 2)In set theory the union of two sets is the list of all elements that appear in
> either (or both) of the sets, and the intersection of the two sets is the list of
> all elements that appear in both sets only. For example, in one set A consists
> of the elements
>
> A={1 3 7 6 2 5}
>
> and a second set B consist of the elements
>
> B={-1 2 0 5 8 9}
>
> then the union of the two sets would be
>
> AUB={-1 0 1 2 3 5 6 7 8 9}
>
> and the intersection of the two sets would be
>
> AnB={2 5}
>
> Write a program that will read in two arrays of integers representing the
> elements of two sets from two different user-specified input files, and
> calculate both the union and the intersection of the two sets. Use arrays to
> contain the input sets, and also to build both the union and the intersection.
> Note that the input sets may not be sorted in order, so your algorithm must
>
I assume he meant "might not be sorted in order". The current wording
suggests that you are prohibited from sorting the arrays. That limits
your options, particularly if you intend to deal with large (billions of
elements) sets.
Cheers,
Bill
> work regardless of the order in which set elements are entered.
>
> Test your program on tww files inputA.dat and inputB.dat, containing the
> following two sets
>
> inputA=0, 1, -3, 5, -11, 6, 8, 11, 17, 15
> inputB=0, -1, 3, 7, -6, 16, 5, 12, 21
>
> If someone could help with some advice or show me how you would solve it I
> would greatly appreciate it.
>
--
Bill Long [log in to unmask]
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120
|