HTW Berlin Medieninformatik

HTW Berlin
Fachbereich 4
Internationaler Studiengang
Internationale Medieninformatik (Bachelor)
Info 2: Informatik II
Winter Term 2010/11


Exercise 11: Scrabble Cheater Basic Edition

Finger exercises :
 

  1. Review the rules of Scrabble, if you have never played it before.
  2. What would the exact data structure be for a hash table that stores Strings and chains the collisions?
  3. What would a normalization function for words look like for a hash? That is, "JAVA" and "VAJA" are permutations, what would a normalized permutation look like?
  4. How do you determine if two strings are permutations of each other?
  5. Review the construction of a hash function. Note that you will need prime numbers. Does your isPrime method work? If not, fix it now.
  6. Can you find lists of valid words for Scrabble in English online? Are there perhaps any sorted by number of letters in the word? Or maybe one file for each word size? Note down the URLs!
In class:

There is a lot to be done here, so have one person focus on making the hash function while the other sets up the data structure. Whoever is done first gets the lookup method sorted out.

  1. Write a dictionary class that upon instantiation reads in a file of words and creates a hash table for storing them. Use chaining of collisions. How many entries does your table have? How many collisions were there? What is the longest chain in your hash table? Some statistical methods might be nice. Can you fix your hash function to have chains of 16 or less?
  2. (For the bored) Can you make a perfect hash? Describe how you went about finding a perfect hash for an extra star.
  3. You will need to have a lookup method in your class that takes a word (i.e. a String) and returns an array of Strings corresponding to all the words at the hash location, if any. You may need to normalize the word to look up, depending on your hash function.
  4. Now make the basic Scrabble cheater - set up a 7-letter-word hash dictionary, set a String to 7 letters, and output the array of Strings found that might be permutations of these 7 letters. Your users can check if there is a permutation to be found. Or you can implement isPermutation and only output the permutations.


Copyright 2010 Prof. Dr. Debora Weber-Wulff
Questions or comments: <weberwu@htw-berlin.de>
Some rights reserved. - Copyright and Warranty