Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in c++ An alternative method for implementing a set S is to imitate the bit string implementation of Delphi by using a boolean array S
in c++
An alternative method for implementing a set S is to imitate the bit string implementation of Delphi by using a boolean array S where S[ch] is true if the element ch is in S and is false otherwise. Using this implementation, write functions for the basic set operations of union, intersection difference, membership, and equality. The rules for the program are 1) Declare a boolean array type which will be mapped from A' to Z. Note that the subscripts are characters so that we can actually test S[ch] directly and loop from 'A' to Z directly in the for loop 2) Create three arrays which will mimic sets: UNIVERSAL, VOWEL and MYNAME. Call a function INIT to initialize these arrays, with UNIVERSAL holding all of the letters, VOWEL contains the letters A, E, I, O and U. Initialize MYNAME to be an empty set, then read a data file which will contain the letters in your name. For ease of input, you can put one letter on each line 3) Create a print function which will be sent one array. The print will be across a row with a space between elements, as in the following format: A BCDEFGHIJKLMNOPQRS TUWX Y Z Call it three times to print the members of UNIVERSAL, VOWEL, and MYNAME, printing an appropriate message each time 4) Write a function which will find the union of any two sets sent to it. Test the function by having it union VOWEL and MYNAME. Call the print function to print this set with an appropriate message 5) Write a function which will find the intersection of any two sets sent to it. Test the function by having it intersect MYNAME and VOWEL. Call the print function to print this set with an appropriate message. 6) Code a function to find the difference of any two sets sent to it. Test the function by having it find the difference of MYNAME and VOWEL. Call the print function to print this set with an appropriate message. 7) Code a function to test if any two sets are equal. Test the function once by sending VOWEL and MYNAME, which are not equal. Then send it MYNAME and MYNAME, where it should be equal. Print the results in each case with an appropriate message
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started