In C++, create a class to hold a set of strings called setTree.setTrees contain copies of the strings inserted so that the stringscannot be changed due to the fact that changing the strings insidethe set could break the binary search tree. The strings are casesensitive.
TreeSet implements the following:
bool add(const string& s) -- add s to the set, if it's notalready there. Return true if the set changed, false otherwise.
void clear() -- remove all elements from the set
bool contains(const string& s) const -- test whether or nots is in the set.
bool isEmpty() const -- test whether or not the set is empty
bool remove(const string& s) -- remove s from the set, if itwas there. Return true if the set changed, false otherwise.
int size() const -- return the number of strings in set.
int toArray(string sa[]) const -- put the elements of the setinto the array sa. Assume that sa has sufficient room (it's theclient's responsibility to check). You can place the strings in anyorder you choose.
The class also includes a zero-argument constructor to create anempty set, a constructor that takes in an array of strings and itssize (creating a set containing each element of the array), copyconstructor, assignment operator, and destructor. The copyconstructor and assignment operator make deep copies.
setTree implements the set using a binary search tree. The treedoes not need to be balanced. The implementation of the tree nodeclass is hidden from the client. There are no memory leaks.