|
This assignment is intended to provide you a good understanding of how to use Hash Tables. One natural use of a set is to hold the words in a spelling dictionary. This makes looking up the words very efficient. In this assignment, you are asked to implement and use such a dictionary. You are responsible for following the rules of good programming style. The first part of the assignment consists in writing a class that implements an Open Hash Table of strings. That is, the table is stored as an array of simple linked lists of strings (or, more precisely, an array of pointers to such lists). You might need to look up the implementation of simple linked list operations in your slides. Your class should be an implementation of the ADT Set of Strings. The class must include: • A function add(s) that adds the string s to the table, if it is not already there. • A function remove(s) that removes the string s from the table, if it's there. • A function contains(s) that returns a Boolean value that checks whether the string s is in the table. • A function size() that returns the number of strings in the table. • A hash function to compute the hash code of a string. This function can be private. • A constructor that accepts the size of the table as a parameter. The second part of the assignment consists of the following: 1. Write a function that takes an input text and broken it up in a list of words, each one per a line. The input must be a text file, and the output is directed to a text file. 2. Write a function that takes an input text (with each word per a line) and create a hash table of an appropriate size for the number of words in the input. It should read the words from the input (text file) and add them to the hash table. You might need to verify, if a word is already exit in the dictionary. 3. Write a function that takes an input text (with each word per a line) and output a list of "near misses". For the search of "near misses", • Construct every string that can be made by deleting one letter from the word. (n possibilities, where n is the length of the word) • Construct every string that can be made by swapping two neighboring characters in the string. (n-1 possibilities). • Construct every string that can be made by inserting any letter of the alphabet at any position in the string. (26*(n+1) possibilities). you should list the near misses in alphabetical order. • Construct every string that can be made by replacing each letter in the word with some letter of the alphabet. (26*n possibilities (including the original word n times, which is probably easier than avoiding it)) The third part of the assignment consists of writing a program with a simple graphical interface that allows the user the following: 1. Browsing for selecting the input file that will be considered as a dictionary, 2. An input area that can be used to enter a text 3. A button "treat" that when pressed, the program outputs the "near misses" of each word given by one of the previous methods
[size=2][size=4]
|