Results 1 to 4 of 4
Thread: Hash Table Help
- 11-26-2008, 03:37 AM #1
Member
- Join Date
- Nov 2008
- Posts
- 4
- Rep Power
- 0
Hash Table Help
1. Implement a HashTableFullException by extending Exception.
2. Implement a closed hash table using a second hash
function (hash2 as defined below) as the increment function. You only
need to implement the following methods: int size(), boolean isEmpty(),
V get (K key), V put (K key, V value), and V remove(K key). The methods
that return a value should return null in the special situations as
discussed in class. Your hash table should not rehash, but instead
should throw the HashTableFullException (as implemented in part 1)
when there is possible overflow. Your remove should use the enhanced
Entry class for lazy deletion. Use Integer objects as keys and
anything you like as the data. Use the function hash1 as defined
below for the hash function and hash2 to do the double hashing.
Name your class DHHashTable.
Your bucket array should have size N = 13.
Use the following hash functions:
hash1(k) = k mod 13
hash2(k) = Rev(k +1) mod 11
You will have to write a Rev method that will reverse the decimal
digits of the key, so Rev(37) = 73 and Rev(7) = 7. You can assume
unique, one or two digit integer keys.
3. Implement a driver that will test the hash table you
developed for part 2. Show the user what keys are being inserted,
retrieved or removed. When there is a collision, tell the user the key
that caused the collision and what alternative probes were made. You
should test the following: create items containing these keys:
2,8,31,20,19,18, 53,27. Insert these items in the order given into
the hash table and display the contents of the hash table, including
the index location of each key as well as any collisions that occured.
Retrieve keys, be sure to illustrate collisions and a key not in the
table. Retrieve after deleting. Insert once requiring throwing the
HashTableFullException. Keep the user informed of the contents of the
hash table when the contents change. Name your driver HashTester.
I have attached the files that I got so far.
-
Rather than posting a homework dump and then your code with the implicit request of "here, fix this for me", you would do much better to isolate what your specific problem, post code relating to only that problem and asking a specific question. Good luck.
- 11-26-2008, 04:42 AM #3
Member
- Join Date
- Nov 2008
- Posts
- 4
- Rep Power
- 0
Need something to get me started
I don't know how to implement the second hash function:confused:
- 11-27-2008, 05:12 PM #4
Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Similar Threads
-
Question about hash tables
By behrk2 in forum New To JavaReplies: 2Last Post: 07-08-2008, 04:40 PM -
Hash table with double hashing
By Java Tip in forum java.langReplies: 0Last Post: 04-12-2008, 08:43 PM -
Hash table with linear probing
By Java Tip in forum java.langReplies: 0Last Post: 04-12-2008, 08:43 PM -
Hash table with separate chaining
By Java Tip in forum java.langReplies: 0Last Post: 04-12-2008, 08:42 PM -
Hash Table help
By rhm54 in forum New To JavaReplies: 0Last Post: 02-08-2008, 01:25 AM


LinkBack URL
About LinkBacks

Bookmarks