Results 1 to 4 of 4

Thread: Hash Table Help

  1. #1
    michael_mke is offline Member
    Join Date
    Nov 2008
    Posts
    4
    Rep Power
    0

    Default 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.
    Attached Files Attached Files

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    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.

  3. #3
    michael_mke is offline Member
    Join Date
    Nov 2008
    Posts
    4
    Rep Power
    0

    Default Need something to get me started

    I don't know how to implement the second hash function:confused:

  4. #4
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    7

Similar Threads

  1. Question about hash tables
    By behrk2 in forum New To Java
    Replies: 2
    Last Post: 07-08-2008, 04:40 PM
  2. Hash table with double hashing
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-12-2008, 08:43 PM
  3. Hash table with linear probing
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-12-2008, 08:43 PM
  4. Hash table with separate chaining
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-12-2008, 08:42 PM
  5. Hash Table help
    By rhm54 in forum New To Java
    Replies: 0
    Last Post: 02-08-2008, 01:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •