in Java 1 class Map 2 { 3 public Map( ) 4 5 public void put( KeyType key, ValueT
ID: 3801793 • Letter: I
Question
in Java
1 class Map
2 {
3 public Map( )
4
5 public void put( KeyType key, ValueType val )
6 public ValueType get( KeyType key )
7 public boolean isEmpty( )
8 public void makeEmpty( )
9
10 private QuadraticProbingHashTable> items;
11
12 private static class Entry
13 {
14 KeyType key;
15 ValueType value;
16 // Appropriate Constructors, etc.
17 }
18 }
Figure 5.55 Map skeleton for Exercise 5.20
5.20
Implement a generic Map that supports the put and get operations. The implementation
will store a hash table of pairs (key, definition). Figure 5.55 provides the Map
specification (minus some details).
5.24
Implement a hopscotch hash table and compare its performance with linear
probing, separate chaining, and cuckoo hashing.
Explanation / Answer
public class HelloWorld{
public KeyType key;
public ValueType val;
public HelloWorld()
{
}
public void put( KeyType key, ValueType val )
{
this.key=key;
this.val=val;
}
public ValueType get( KeyType key )
{
this.val=(ValueType)key;
return val;
}
public boolean isEmpty( )
{
return false;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.