Home > Uncategorized > java hash table code

java hash table code

JAVA Hashinsh.. is my code correct?

Create a method that will hash a String Value to an int key. The parameters to this method should
be the Value, and the size of the hash table (M) that you’ll use for determining the hash key.

public void hash(String Value, int size){
String[] hashtable = null;

hashtable = new String[size];
for(int x=0; x hashtable[x]=null;

int key = Value.hashCode();
}

Um. No.

public int hash(String value, int m) {
return value.hashCode() % m;
}

CS 61B Lecture 4: Types and Conditionals

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.

Comment moderation is enabled. Your comment may take some time to appear.