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 6897655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:11:47+00:00 2026-05-27T07:11:47+00:00

Attempting to better understand chaining on a hashtable. Seeking a simple table that hashes

  • 0

Attempting to better understand chaining on a hashtable. Seeking a simple table that hashes a value and only associates one integer to the value hashed. Here is sample code of the problem in question…

      /* hash string value return int */
      public int hashFunction(String D) {
          char[] Thing = D.toCharArray();
          for(int i=0; i < Thing.length; i++){
             index += Thing[i]; }
          return index % TABLE_SIZE;          
      }

      /* hash string value return void */
      public void hashFunction(String D) {
        char[] Thing = D.toCharArray();
        for(int i=0; i < Thing.length; i++){
         index += Thing[i];}
        int hash = index % TABLE_SIZE;
        if(table[hash] == null){
          table[hash] = new HashEntry( Level,  Value );
        }        
        else{
          table[hash].setNext(nd);
        }
      }

      /* miscellaneous code snippet */
      if(table[hash] == null){
        table[hash] = new HashEntry();
      }

      else if (Data.compareTo("VAR") == 0) {
          Data = inFile.next();   
            char[] Thing = Data.toCharArray();
            for(int i=0; i < Thing.length; i++){
            hash += Thing[i];}
            hash = hash % TABLE_SIZE;           
            hm.setIntoHashTable(hash);      
                Data = inFile.next();
                    if(Data.compareTo("=") == 0) {
                    Data = inFile.next();
                    int value = Integer.parseInt(Data);
                    hm.getIntoHashTable(he.setValue(value));
                }
      }
  • 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-27T07:11:48+00:00Added an answer on May 27, 2026 at 7:11 am

    Well the chaining occurs when you have collision in the indexes.

    Lets assume you have a TABLE_SIZE=10

    Now you have to store string abc, so you get hash as 4

    Now when you gonna store string cba, you end up with same hash 4

    So now to store cba at the same index, you will create and store a List at index 4.

    The List will contain both abc and bca. This List is called chain and this process of storing multiple values at the same hash is called Chaining.

    Pseudo code look like:

    if(table[hash] == null)
      table[hash] = new ArrayList<HashEntry>();//APPEND ON TO THE LOCATION ALREADY THERE!
    table[hash].add(new HashEntry());
    

    The table will be declared as:

    @SuppressWarnings("unchecked")
    List<HashEntry>[] table = new List[TABLE_SIZE];
    

    You might have to suppress warning as arrays and generics dont go smoothly.

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

Sidebar

Related Questions

Attempting to insert an escape character into a table results in a warning. For
Attempting to print out a list of values from 2 different variables that are
Attempting to make a NSObject called 'Person' that will hold the login details for
When attempting to understand how a SQL statement is executing, it is sometimes recommended
i'm attempting to implement a mouse event where Mouse_Move can only occur if Mouse_Down.
I am attempting to complete the following how-to in order to try and understand
I am learning SQL and DB design for a college class. One assignment that
Am attempting to subclass UIAlertView to better handle error states in my app. The
Attempting to use asp.net mvc's Action Result of File. So it would seem that
I'm attempting to pull a list of files that changed during a range of

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.