CSL201: Assignment 2

Due Date : August 26, 2013

Maintaining a Dictionary of Words

In this assignment you will build a dictionary for stroing words and their meanings. Your program should be able to read data from a file. The file contains some integers and some words. The first entry is guaranteed to be an integer. Depending on the value of the integer your program should do the following:

1 Keep on reading words till you come across the next integer. Put the words on linked list A. Print the list.

2 Sort the words of list A in dictionary style and print the list.

3 Read the word following it and insert it in the sorted list A. Print the list.

4 Read the word and search list A to locate the word. Print a message indicating the node number containing the word. If word is not found print an appropriate message.

5 Read the word following it, and delete the node containing the word from list A and print the list.

6 Go through list A and check if any word occurs more than once. Just keep one copy of the word and delete the other occurrences. print the list.

7 Keep on reading words till you come across the next integer. Make a new list B with these words, sort it and print list B. Next merge lists A and B so that the words are still in sorted order, print the merged list. (You are not allowed to join the two lists and use the sorting routine).

8 Print your name and entry number and terminate the program.

Note: Every print should start from a new line.

Sample input file:

1 N D G T 2 3 K 3 K 6 7 X L B P

N D G T

D G N T

D G K N T

D G K K N T

D G K N T

B L P X

B D G L N P T X





Your program should be in C++ and should use standard object oriented features of C++. Your implementation of linked list should use a generic type (templates).