Question: Java Quadratic Probing and Lazy Deletion You will be implementing hashtable which uses quadratic probing with Lazy Deletion strategy. If the hash table reachese/exceeds 40%

Java Quadratic Probing and Lazy Deletion

You will be implementing hashtable which uses quadratic probing with Lazy Deletion strategy. If the hash table reachese/exceeds 40% full, you will have to rehash it

Java Quadratic Probing and Lazy Deletion You will be implementing hashtable which

public class QuadraticProbing private static final int DEFAULT-TABLE-SIZE = 13; private HashEntry[ array; I/ The array of elements public static class HashEntrycAnyTypex /* initialize the entries here. You can write a constructor for the same */ public AnyType element; public boolean isActive For Lazy deletion public String toString0x if(this.element!-null) return (String) element; else return "NULL"; Construct the hash tablel public QuadraticProbing() this( DEFAULT_TABLE_SIZE); Construct the hash tablel public QuadraticProbing( int size)f allocate memory to hash table '/ * Return true if currentPos exists and is active - Lazy Deletion' public boolean isActive(int position) f return false Find an item in the hash table. " public boolean contains(AnyType x) Should return the active status of key in hash table return false Insert into the Hash Table */ public void insert(AnyType x X Insert an element */ Remove from the hash table. public void remove( AnyType x X Lazy Deletion/ * Rehashing for quadratic probing hash table/ private void rehash(X Resize the hashtable such that the new size is the first prime number greater than two times the current size For example, if current size is 5, then the new size would be 11 Hash Function public int hash( String key, int tableSize X Make sure to type cast "AnyType" to string before calling this method ex: if "x" is of "AnyType you should invoke this function as hash((.toString()), tableSize) int hashVal = 0; P Compute the hash code return hashVal public int probe(AnyType xX Return the number of probes encountered for a key / int num_ of probes 0; return num_of probes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!