Hash Tables

CISS-111 Project 6

Write a Java program to demonstrate using hash tables. Doing more file processing, you will read in a dictionary file, [url removed, login to view], and use its contents to spell check a file, checkme, that is provided on the command line.

This project is not an in-depth, comprehensive program in the nature of root words, tense, plurals or endings. Rather many words of varying form (plurals, possessives) will be provided in the dictionary file.

You will need to create two Java files: [url removed, login to view] and


•A file of 125,000+ dictionary words.

•A file to be spell checked provided on the command line.

•A hash multiplier of 31.

•A bucket value of 4093.

Create a StringHash class. Here is some code to get you started:

1 public class StringHash {


3 Node[] buckets;

4 private int BUCKETS;

5 private int MULT;


7 public int hashValue(String s) {

8 int h;

9 int x, l = [url removed, login to view]();


11 h = 0;

12 for ( x =0; x < l; x++ )

13 h = h * MULT + [url removed, login to view](x);


15 if ( h < 0 )

16 h = -h;


18 return (h % BUCKETS);

19 }

You will need to create a constructor and a Node inner-class similar to the Linked-List topic.

Create the following methods in a newly created StringHash class:

public boolean hasWord(String word);

public void add(String word);

Now create a Project6 class for testing the StringHash class. This class will also have your main() method. Use the following in the Project6 class:

1 public static String removeNonLetDig(String s) {

2 int b = 0, e = [url removed, login to view]()-1;


4 // Trim from the beginning

5 while (b <= e && ![url removed, login to view]([url removed, login to view](b)))

6 b++;


8 // Trim from the end

9 while (e >= b && ![url removed, login to view]([url removed, login to view](e)))

10 e--;


12 if (b <= e)

13 return [url removed, login to view](b,e + 1);

14 else

15 return null;

16 }

Note: this is from the Short-Circuit discussion.

The remainder of this work should be done in the Project6 class.

Your input file will be given on the command line. The dictionary file should be hard coded as dictionary.txt.

Read the dictionary file into the hash table using the add() method. Use the hashValue() method to find the appropriate bucket for a given word. Once a bucket is found add the word to the list for that bucket. An ordered list is not needed here as a linear search of the bucket list should not be too expensive due to the hash.

*NOTE*: You must either lower case or upper case the words as they are entered into the hash table.

Lookups will be consistent later as hasWord() must do the same when you request a word lookup.

After the hash table is populated with the dictionary words, open the file to be spell checked and read words from the file one at a time. Check the word against the hash table using hasWord().

Display to standard output those words that are not spelled correctly or do not appear in the hash table. Your output should look like:



[url removed, login to view]



[url removed, login to view]














A few additional notes to make life easier:

•The hasWord() method should consider a null reference a valid word.

•The removeNonLetDig() method is designed to remove surrounding punctuation on a word. Since we can use the next() Scanner method to read a word from the file, white-space is not a problem, but a word at the end of a sentence or part of a quotation may have leading or trailing non-letter or non-digit characters.

Be sure you submit both files for grading.

Habilidades: Programação C, Java

Veja mais: two string problem, substring search, substring in c, substring find, substring c, substring 0 2, string processing in c, string hash, string find c, search substring, search character in string, scanner programming, programming of life, programming hash, programming dictionary, one word for many words dictionary, non linear programming, node programming, linked int, linear programming word problem, linear programming standard form, linear programming project, linear programming problem, life programming, java programming from the beginning

Acerca do Empregador:
( 5 comentários ) Albany, United States

ID do Projeto: #5133569

Concedido a:


A proposal has not yet been provided

$20 USD em 3 dias
(3 Comentários)

4 freelancers are bidding on average $25 for this job


Hi I am Expert In JAVA and ALGORITHM Check my GoogleCodeJAM Code [url removed, login to view] I can do your work very fast and efficiently Thank You :)

$25 USD in 2 dias
(6 Comentários)

Dear project owner, I'm an expert in Java. I have several Sun certifications about Java including SCJP and SCWCD and I'm sure that I can handle this task. Let me to handle this and I'll give you the result with highest Mais

$30 USD em 1 dia
(12 Comentários)

Hello, I don't have so many professional skill in Java. But this must be an easy project. I am very happy if you let me handle this. Thanks. Van Pham.

$25 USD in 10 dias
(2 Comentários)