In Java, Write The SeperateChainingHashST Class. Insert The Keys, \"H A T R Q U Z I O V\" In The Order Given Into An Empty Table Of M=5 Lists Using Separate Chaining. Use The Hash Function (11 * K) % M To Turn The Kth Letter Of The Alphabet Into

匿名用户 最后更新于 2021-12-01 19:36 计算机类Computing

In Java, write the SeperateChainingHashSTclass.

Insert the keys, "H A T R Q U Z I O V" in the order given intoan empty table of M=5 lists using separate chaining.

Use the hash function (11 * k) % M to turn thekth letter of the alphabet into a table index.

Given code:

public class SeperateChainingHashST {
private int M=5;
private Node[]st = new Node[M];
private static class Node
{
private Object key;
private Object val;
private Node next;

}
private int hash(Key key)
{
return
}

public void add(Key key, Value val)
{
int i=hash(key);
for (Node x = st[i]; x!= null; x=x.next)
if(key.equals(x.key))
{
x.val=val;
return;
}
st[i]= new Node(key, val, st[i]);
}

public static void main(String[] args) {


}

}

已邀请: