Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in C that represents sets of strings as linked lists. Must be wr

ID: 3573242 • Letter: W

Question

Write a program in C that represents sets of strings as linked lists. Must be written in C only. Thank you.

In this program you will represent sets of strings as linked lists. Each node will hold one string and the strings will appear in alphabetical order in the list. Thus the set containing the strings "one", "two" and "three" will be represented as:

Internals

You will write code to manipulate sets represented as above using linked lists. None of the required operations is difficult but some thought is in order. Special care must be taken to make sure that you free() all memory allocated with malloc(). This can be very tricky. You should check for memory leaks with valgrind though you will not be required to submit your valgrind results.

The calculator will consist of an array of head pointers, each indicating the beginning of a set. Initially each pointer will point to a dummy node and there will be no other nodes in the lists (this indicates empty sets). The set operations are the ones you learned in middle school and should require no further explanation.

All lists are kept in alphabetical order. Adding a string to a list will require that you place it in the proper alphabetical position. To do this you may use the following function which is a replacement for strcmp(). (Remember to #include <ctype.h>.)

If an attempt is made to insert a string into a set which already contains that string the insertion will be ignored: strings in a set must be unique. Two string with different use of upper and lower case will be considered the same: for example "snargle" and "SnaRgle" are the same string.

Note: do not use "union" as an identifier in your program -- it is a keyword in C.

Validation

All user input must be validated. The user's choice of operation will be entered as as single character (scanf(" %c", &choice);). If the choice is invalid your program will prompt for another choice. If the user asks for a set whose number is not in the range 0 through 9 a polite error message will be given and the user will be asked to try again.

head dummy one three two

Explanation / Answer

add string (a)

remove string (r)

union (u)

intersection (i)

symmetric difference (s)

copy (c)

clear (z)

print set (p)

quit (q)

a

Set: 1

string: one

add string (a)

remove string (r)

union (u)

intersection (i)

symmetric difference (s)

copy (c)

clear (z)

print set (p)

quit (q)

a

Set: 1

string: two

add string (a)

remove string (r)

union (u)

intersection (i)

symmetric difference (s)

copy (c)

clear (z)

print set (p)

quit (q)

a

Set: 2

string: three

add string (a)

remove string (r)

union (u)

intersection (i)

symmetric difference (s)

copy (c)

clear (z)

print set (p)

quit (q)

a

Set: 2

string: one

add string (a)

remove string (r)

union (u)

intersection (i)

symmetric difference (s)

copy (c)

clear (z)

print set (p)

quit (q)

a

Set: 2

string: four

add string (a)

remove string (r)

union (u)

intersection (i)

symmetric difference (s)

copy (c)

clear (z)

print set (p)

quit (q)

s

destination set: 3

first operand: 1

second operand: 2

add string (a)

remove string (r)

union (u)

intersection (i)

symmetric difference (s)

copy (c)

clear (z)

print set (p)

quit (q)

p

Set: 3

{four,three,two}

add string (a)

remove string (r)

union (u)

intersection (i)

symmetric difference (s)

copy (c)

clear (z)

print set (p)

quit (q)

p

Set: 2

{four,one,three}

add string (a)

remove string (r)

union (u)

intersection (i)

symmetric difference (s)

copy (c)

clear (z)

print set (p)

quit (q)

p

Set: 1

{one,two}

add string (a)

remove string (r)

union (u)

intersection (i)

symmetric difference (s)

copy (c)

clear (z)

print set (p)

quit (q)

q

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote