In Java, Write The SeperateChainingHashST Class. Insert The Keys, \

匿名用户 最后更新于 2021-11-29 17:10 计算机类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) {


}

}

已邀请: