Lab Assignments




  1. Set operations using arrays: Union, intersection, membership and difference need to be implemented. Subset is an extra requirement that people interested can implement. For union, intersection, difference and subset, the input is the names of two files. Each file contains the integers that are part of the set, one number per line. You have to read from the file into an array. Make this a function as part of modularity. This function can then be reused for many other lab assignments. For membership, accept the name of a file containing the set elements as input. In addition, accept a value and verify if it is a member of the set or not. Also write a function to print the arrays so that the final set can be printed for union, intersection, difference. The return value from the functions in membership and subset is a boolean that returns TRUE (1) if true and FALSE (0) if false. For union, intersection and difference, the parameters to the functions are the two input arrays and a third array that is the output array. The return value from these functions is the number of elements in the output array.