Project Implement Set Abstract Data Type Strings Interface Implementation Must Kept Separa Q43875708
In this project, you will implement a set abstract data type forstrings. Your interface and implementation must be kept separate.Separate source files that provide main will be provided fortesting your data type.
2 Interface
The interface to your abstract data type must provide thefollowing operations:
SET *createSet(int maxElts);
return a pointer to a new set with a maximum capacity ofmaxElts void destroySet(SET *sp);
deallocate memory associated with the set pointed to bysp int numElements(SET *sp);
return the number of elements in the set pointed to bysp void addElement(SET *sp, char *elt);
add elt to the set pointed to by sp
void removeElement(SET *sp, char *elt);
remove elt from the set pointed to by sp
char *findElement(SET *sp, char *elt);
if elt is present in the set pointed to by spthen return the matching element, otherwise return NULL char**getElements(SET *sp);
allocate and return an array of elements in the set pointed toby sp
Implementation
The interface to your abstract data type must provide thefollowing operations:
You will write two different implementations of the data typefor this assignment. First, implement a set using an unsorted arrayof length m > 0, in which the first n ≤m slots are used to hold n strings in somearbitrary order. Use sequential search to locate an element in thearray. Second, implement a set using a sorted array of lengthm > 0, in which the first n ≤ m slotsare used to hold n strings in ascending order. Use binarysearch to locate an element in the array.
For both implementations, rather than duplicating the searchlogic in several functions, write an auxiliary func- tion searchthat returns the location of an element in an array. Declare searchas static so it is not visible outside the source file. Use searchto implement the functions in the interface. Your implementationshould allocate memory and copy the string when adding, andtherefore also deallocate memory when removing.
By the end of the first lab, you should have finished the firstimplementation. You should verify that the ADT works with both testprograms (unique, and then parity) on all of the files. Note thatunique takes an optional second file, whose words it removes fromthe set, thus allowing you to test insertion followed by deletion.In contrast, parity interweaves insertion and deletion, so it is atougher test. By the end of the second lab, you should havefinished both implementations. Before the due date, make sure youfinish commenting and testing your code. You should use the assertmacro defined in <assert.h> where appropriate.
Expert Answer
Answer to In this project, you will implement a set abstract data type for strings. Your interface and implementation must be kept…
OR