Question

This should be in Java Create a simple hash table You should use an array for...

This should be in Java

Create a simple hash table

  • You should use an array for the hash table, start with a size of 5 and when you get to 80% capacity double the size of your array each time.
  • You should create a class to hold the data, which will be a key, value pair
  • You should use an integer for you key, and a String for your value.
    • For this lab assignment, we will keep it simple
  • Use a simple hash function
    • If your key is an integer, just mod by the table size
    • Your key can be the integer value in the data
  • For collision resolution, use open addressing with Linear Probing

    Your program should include:

    • A class to hold the key-value pairs
    • A class to hold the array of key-value pairs
    • A method to add data to the table
      • Since the hash function and collision resolution method are so simple, you could include them in this method, or you could write separate methods for them.
      • You should read your input from a file, I will write up a test file to test your code. The input file will look like this:
                                   39482 Sam
                                   359353 Luck
                                   977535 Barney
                                   546943 Moe
                                   70984  Dr.Max
                                
    • A method to double the size of the array when needed, and a rehash method to go along with it.
    • A way to print out the contents of the hash table for testing.
    • You may test your program with a separate class for the driver, or just put a main method in the same class as the array of key-value pairs.
    • You should implement a search method: Given a key, return the value associated with that key.
    • Put in a delete method that doesn't mess up the hashing indexes.
    • Make sure you aren't rehashing deleted items when you double the size of the array.
0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
This should be in Java Create a simple hash table You should use an array for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • IN JAVA USING ECLIPSE The objective of this assignment is to create your own hash table...

    IN JAVA USING ECLIPSE The objective of this assignment is to create your own hash table class to hold employees and their ID numbers. You'll create an employee class to hold each person's key (id number) and value (name). Flow of the main program: Create an instance of your hash table class in your main method. Read in the Employees.txt file and store the names and ID numbers into Employee objects and store those in your hash table using the...

  • IN JAVA LANGUAGE: For this lab you are required for implement the following methods: 1. public...

    IN JAVA LANGUAGE: For this lab you are required for implement the following methods: 1. public QuadraticProbingHashTable( int size ): As the signature of this method suggests, this is a constructor for this class. This constructor will initialize status of an object from this class based on the input parameter (i.e., size). So, this function will create the array HashTable with the specified size and initialize all of its elements to be null. 2. public int hash(int value, int tableSize...

  • The task of this project is to implement in Java Hash Table structure using Linear Probing...

    The task of this project is to implement in Java Hash Table structure using Linear Probing Collision Strategy.   You can assume that no duplicates or allowed and perform lazy deletion (similar to BST). Specification Create a generic class called HashTableLinearProbe <K,V>, where K is the key and V is the value. It should contain a private static class, HashEntry<K,V>. Use this class to create array to represent Hashtable:             HashEntry<K,V> hashtable[]; Implement all methods listed below and test each method...

  • Java using data structures The objective is to create your own Hash Table class to hold...

    Java using data structures The objective is to create your own Hash Table class to hold a list of employees and their ID numbers. I've provided the TableEntry class which will be each data object in the hash table. The list of employees will be provided as a .txt file and must be read with the code. please create a .txt file called Employees.txt with the info provided so that the java code can read it in. Employees.txt: (No WhiteSpace...

  • Create a hash table class/struct.in C++ Define an array that holds 27 elements. Define a function...

    Create a hash table class/struct.in C++ Define an array that holds 27 elements. Define a function called Hash(int) -This function returns the modulo of that int by the size of the table (array). Define an add function that takes an integer. -This function takes the integer, determines the hash of that number by calling the above hash function, then adds it to the table using linear probing for collision resolution. Define a function that looks up a value, it takes...

  • please use Java!! We are storing the inventory for our fruit stand in a hash table....

    please use Java!! We are storing the inventory for our fruit stand in a hash table. The attached file shows all the possible key/fruit combinations that can be inserted into your hash table. These are the real price lookup values for the corresponding fruit. Problem Description In this programming assignment, you will implement a hash table class fruitHash. Your hash table must include the following methods: 1) hashFunction(key) This method takes a key as an argument and returns the address...

  • Insert elements into a hash table implemented using chain hashing, as an array of linked list...

    Insert elements into a hash table implemented using chain hashing, as an array of linked list in which each entry slot is as a linked list of key/value pairings that have the same hash (outcome value computed using certain hash function). You are allowed to use “Hash Function”, h(k) = k % x where, x is the value you will need to decide to use, that you find appropriate for this implementation. The main requirements are the following: 1. Input:...

  • Design a primary hash table data structure. a. Each hash table has an array of node...

    Design a primary hash table data structure. a. Each hash table has an array of node pointers and can point a head of a linked list. Suppose the node class is given to you. The data type of each node is int. b. Override the default constructor with a constructor that has one default parameter called capacity. What happens to your default constructor? Create some instances of the sequence class using the new constructor in multiple ways. c. Design the...

  • create a hash table to implement spell checker in java 1. Create a file of 100...

    create a hash table to implement spell checker in java 1. Create a file of 100 words of varying length (max 8 characters). 2. All the words are in lower case. 3. design a hash table. 4. enter each word in the hash table. Once the hash table is created, run it as a spell checker.enter a word (interactive), find the word in the hash table. If not found enter an error message. Then prompt for next word. End the...

  • Please complete the following task: Create a C++ hash table program for generating a hash from a string. Create a hash f...

    Please complete the following task: Create a C++ hash table program for generating a hash from a string. Create a hash function then test and evaluate the results. The set of strings are from a "words.txt" file (there are 45,402 words in the file, no repeating words. Map the words to 45,402 buckets using a hash function). Requirements: Create an array of 45,402 integers and initialize each to zero. These will be used to store how many times each index...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT