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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:00:39+00:00 2026-06-14T19:00:39+00:00

So I am creating a Hash Table that uses an Array of Linked Lists

  • 0

So I am creating a Hash Table that uses an Array of Linked Lists of Arrays. Let me take a second to explain why this is.

So I have previously implemented Hash Tables by creating an Array, and each element of the array is a Linked List. This way I could quickly look up a LL of 450,000 elements by searching for the hash value first in the array, and searching the elements of this LL. I should add that this is a project for school and I cannot just use the Hash Tables that comes with java.

Now I want to do something similar… but I massive have a LL of Arrays that I need to search. Here each element of the LL is line of a text file, which represented by a 4 element array, where each of the 4 elements is a different string that was tab delimited in the input file. I need to be able to quickly access the 2nd, 3rd, and 4th string that was located in each line, and that is now an element of this array.

So What I want is to be able to create an Array of LL of Arrays… first I will find the sum of the ascii values of the second element of an array. Then I will hash the entire array using this value into by Hash Table. Then when I later need to find this element, I will go to the corresponding element of the array, where I have a list of arrays. I will the search for the 2nd value of each array in the list. If i find the one I want, then I return that array, and use the 3rd and 4th element of this array.

As I said, I have this working fine for an Array of LL, but adding the extra dimension of Arrays inside has thrown me off completely. I think it is mostly just figuring out syntax, since I have successfully initialized a Array of LL of Arrays (public static LinkedList[] RdHashLL) so it appears that Java is okay with this in principal. However, I have no idea how to put elements into the Hash Table, and how to read them out.

Below is my code for a ARRAY OF LINKED LISTS that works FINE. I just need help getting it to work for an ARRAY OF LL OF ARRAYS!

public class TableOfHash{

public static LinkedList<String>[] HashLL;

//HASH FUNCTION - Finds sum of ascii values for string
public static int charSum(String s){
    int hashVal = 0;
    int size = 1019; //Prime Number around size of 8 char of 'z', (8 chars is amoung largest consistantly in dictionary)

    for(int i = 0; i < s.length(); i++){
        hashVal += s.charAt(i);
    }   
    return hashVal % size;
}

//CREATE EMPTY HASH TABLE - Creates an array of LL
public static void makeHash(){
    HashLL = new LinkedList[1019];
    for(int i=0; i<HashLL.length; i++){
        HashLL[i] = new LinkedList<String>();
    }
}

//HASH VALUES INTO TABLE!
public static void dictionary2Hash(LinkedList<String> Dict){
    for(String s : Dict){
        HashLL[charSum(s)].add(s);
        //Finds sum of char vales of dictionary element i,
        //and then word at i to the HashLL at point defined
        //by the char sum.
    }   
    //Print out part of Hash Table (for testing! for SCIENCE!)
    //System.out.println("HASH TABLE::");
    //printHashTab();
}

//SEARCH HashTable for input word, return true if found
public boolean isWord(String s){

    if(HashLL[charSum(s)].contains(s)){
        wordsfound++;
        return true;
    }
    return false;
}

}

I have made some attempts to change this, but for things like if(HashLL[charSum(s)].contains(s)) which searches the LL at the element returned by charsum(s)… I have no idea how to get it to work when it is a LL of Arrays and not of Strings. I have tired HashLL[charSum(s)].[1].contains(s)), and HashLL[charSum(s)][1].contains(s)), and various other things.

The fact that a Google search for “Array of Linked Lists of Arrays” (with quotes) turns up empty has not helped.

Last bit. I realize there might be another data structure that would do what I want, but unless you believe that a Array of LL of Arrays is a totally hopeless cause, I’d like to get it to work as is.

  • 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-06-14T19:00:40+00:00Added an answer on June 14, 2026 at 7:00 pm

    if you have

    LinkedList<String[]>[] hashLL;
    

    you can read a specific String like this (one of many ways)

    String str = hashLL[outerArrayIndex].get(listIndex)[innerArrayIndex];
    

    To write into the fields, this is possible (assuming everything is initialized correctly).

    String[] arr = hashLL[outerArrayIndex].get(listIndex);
    arr[index] = "value";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im toying with creating my own hash table data structure, but I have hit
I am creating a program that uses an array of objects declared with Element
I am working with a ruby hash that contains key/value pairs for creating a
I will see if I can explain this clearly enough. I have 2 web
I'm creating a hash table in Perl, of an unknown size. The hash table
I am creating a simple hash table in VS 2008 C++. #include <map> std::map
So I've been working on program in which I'm creating a hash table in
I'm in a data structures class and we have an assignment that includes creating
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
(creating a separate question after comments on this: Javascript redeclared global variable overrides old

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.