COMP2000 Assignment 6 Thesaurus solved


Category: You will receive a download link of the .ZIP file upon Payment


5/5 - (1 vote)

Name of program: thesaurus.c
Write a program to read and store a thesaurus as follows:

Data for the program consists of lines of input. Each line contains a (variable) number of distinct words, all of which are synonyms. You may assume that words consist of letters only and are separated by one or more blanks. Words may be spelt using any combination of upper and lower case letters. All words are to be stored in a hash table using “open addressing with double hashing”. A word can appear on more than one line, but each word must be inserted only once in the table. If a word appears on more than one line then all words on those lines are considered synonyms. This part of the data is terminated by a line containing the word ENDOFSYNONYMS.

The data structure must be organized such that, given any word, all synonyms for that word can be quickly found.

The next part of the data consists of several commands, one per line. A valid command is designated by P, A, D or E.

P word prints, in alphabetical order, all synonyms of word.
A word1 word2 adds word1 to the list of synonyms for word2.
D word deletes word from the thesaurus.
E, on a line by itself, indicates the end of the data.