Lab 10 Linear Probing

Linear Probing代写 The questions in this worksheet all relate to the map data structure. This will be implemented using an array and the open…

The questions in this worksheet all relate to the map data structure. This will be implemented using an array and the open addressing collision strategy.

Complete the methods in the LPMap class provided.

For this assignment each entry will have an integer KEY a nd a string VALUE. FOR EXAMPLE: (100, China), (259, USA) , (31, Iran), (40, Ireland).

Question 1 Linear Probing代写

Implement a constructor for the LPMap class. In this class, an array is created to store all the entries. Create a constructor which should initialize the array with the indicated size.

Question 2

Implement the hashCode method in the class. This method should use the MAD method to compress the key into the correct range. HashCode is X Mod 13. X is the key of an entry and the hashcode will be the remaining part of X divided by 13.

Question 3

Complete the implementation of the find method. This method should search the array. The method should return the index that the entry is stored in.

Linear Probing代写
Linear Probing代写

Question 4 Linear Probing代写

Complete the implementation of the get method. Remember that this method should return the value that is associated with the key or null if it is not present

Question 5

Complete the implementation of the remove method. This should remove the position from the array where the key matches the parameter. The value that was linked with this key should be returned. If there is no matching key, then null should be returned.

Question 6 Linear Probing代写

Complete the implementation of the put method. This should add the new key and value to the map. If there is an entry in the array with the same key this should be removed and the value inside it returned. If there is no entry in the array with the same key, then null should be returned.

 

Question 7

For this assignment each entry will have an integer KEY and a string VALUE. FOREXAMPLE: (100, China), (259, USA) , (31, Iran), (40, Ireland).

To test all the methods of your List MAP ADT create a main method that:

  1. Creates a List Map with the entries in the example above. Linear Probing代写
  2. Put entry: (1, Malaysia) , Put entry (65, Thailand)
  3. Remove (3, USA),
  4. Remove (4, Ireland)
  5. Get the entry with key 2

The result of this should be printed to the console.