Question: Consider the following method that implements adding a key/value pair to a linear probing hashtable: public void put(key key, Value val) { if (N >=

Consider the following method that implements adding a key/value pair to a linear probing hashtable: public void put(key key, Value val) { if (N >= M/2) resize(2*M); int i; for (i = hash(key); keys[i] != null; i = (i + 1) % M) if (keys[i].equals(key)) { //THIS LINE HERE vals[i] = val; return; } keys[i] = key; vals[i] = val; N++; } What is the purpose of the indicated line? To check if the key produces a valid hashcode. To check if there is a space in the array for the new element at the current position. To check if the key already exists in the keys array. To check if if the value in the array is different than the argument
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
