[Solved] COMP 2000 Assignment 4

$25

File Name: COMP_2000_Assignment_4.zip
File Size: 207.24 KB

SKU: [Solved] COMP 2000 Assignment 4 Category: Tag:
5/5 - (1 vote)

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. The data structure must be organized such that, given any word, all synonyms for that word can be quickly found. A word can appear on more than one line. If a word appears on more than one line then all words on those lines are to be considered synonyms.

After the complete thesaurus has been built, print an alphabetical listing of the words and their synonyms.

Print another alphabetical listing but, this time, each word is printed once only. That is, if a word is already printed as a synonym of another word then it does not appear in the listing again.

Sample input

blossom flower

bewilder confound confuse perplex

dwell live reside

Sample output

Words Synonyms

bewilder confound confuse perplex

blossom flower

confound bewilder confuse perplex

confuse bewilder confound perplex

dwell live reside

flower blossom

live dwell reside

perplex bewilder confound confuse

reside dwell live

Words Synonyms

bewilder confound confuse perplex

blossom flower

dwell live reside

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COMP 2000 Assignment 4
$25