linhash-f11

linhash-f11 - University of Arizona CSc345 (Fall 2011; B....

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
University of Arizona CSc345 (Fall 2011; B. Moon) CSc 345 Programming Assignment #2 Static Hashing vs. Dynamic Hashing Problem Statement For this assignment, we design an electronic dictionary with spelling checker. In order to practice building different hash tables, the dictionary will be implemented by two static hashing schemes, one with a quadratic probe sequence and the other with a pseudo-random probe sequence, and a dynamic hashing scheme called linear hashing . Assume that all the words in the dictionary are unique. You are to write Java classes that implement the CHashQuad , CHashRand , and LinearHash ADTs. Each of these ADTs implements a Dictionary interface using a different hashing scheme. Skeleton classes for all of these ADTs, a test main class MainHash.java , and a utility class are available in the D2L site. You should copy them to your working directory. You should then provide implementations for all the methods defined in the skeleton classes. You can add more methods as you wish, but are not allowed to remove any methods defined in the skeleton classes. You need to implement the following class methods for CHashQuad . 1. The CHashQuad(int HTinitSize) constructor creates an empty hash table with HTinitSize slots. (Let M denote the value of HTinitSize .) 2. The insert(String word) method inserts word into the hash table, and returns the index of the hash table entry to which the word is inserted. Whenever a collision occurs, find a free slot following a quadratic probe sequence . To avoid any potential infinite looping, we limit the length of the probe sequence to M . Thus, if none of the hash entries at ( h ( word ) + i 2 ) mod M for 0 i < M is empty, then the insertion fails and
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/28/2012 for the course CSC 345 taught by Professor Moon during the Fall '11 term at Arizona.

Page1 / 2

linhash-f11 - University of Arizona CSc345 (Fall 2011; B....

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online