Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6786535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:15:25+00:00 2026-05-26T17:15:25+00:00

Possible Duplicate: The fundamentals of Hash tables? I am trying to implement a Simple

  • 0

Possible Duplicate:
The fundamentals of Hash tables?

I am trying to implement a Simple Hash Table probably with simple java arrays. But 1st I will need to somehow have an associative array or sorts? How might a simple Hash Table implementation look like? It should still be able to do add/delete/get in O(1)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:15:26+00:00Added an answer on May 26, 2026 at 5:15 pm

    A hash table basically takes an input key, hashes it with a function to find a bucket ID, and then uses that bucket ID to either store or retrieve the data associated with that key.

    In other words, for your case, you just have to provide a hashing function on your data that will give you a bucket ID of your array index.

    Perhaps the simplest (and most naive) would be exclusive ORing together all the characters of your key then doing a modulus operation to bring it to the desired range. For example, say you have a structure containing:

    • Name
    • Address
    • Phone
    • All sorts of other details

    You could generate a hash as follows:

    set hashval to zero
    for each character in Name:
        hashval = hashval xor character
    hashval = hashval mod 256
    

    This would give you a bucket ID of between 0 and 255 inclusive.

    Just keep in mind that the bucket may contain more than one item so you can’t just use the bucket ID as an array index. Each bucket will need to be a structure containing possibly multiple items (such as a linked list or even another hashtable).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Working with latitude/longitude values in Java Duplicate: Working with latitude/longitude values in
Possible Duplicate: array_splice() for associative arrays How to add an array value to the
Possible Duplicate: Is Java pass-by-reference? I found an unusual Java method today: private void
Possible Duplicate: What to do when I want to use database constraints but only
Possible Duplicate: How do I make a list with checkboxes in Java Swing? I
Possible Duplicate: How can I increment a date by one day in Java? I
(This is probably a duplicate, but I could not find it - feel free
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicate: Catching java.lang.OutOfMemoryError OutOfMemoryError are: Thrown when the Java Virtual Machine cannot allocate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.