Note
- Trying to find the next empty bucket for the conflicted key-value pair linearly
Uses Pseudorandomness to find the next empty bucket for conflicted key-value pair
Mechanism
Search key-value pair with key
- Obtain the Array index by passing the key to the Hash Function
- If the key-value pair in the bucket doesn’t match with the key, iterate through the buckets linearly until the correct key-value is found
- Else, if the bucket is empty, then key-value pair isn’t inside, return None
Add key-value pair
- Obtain the Array index by passing the key to the Hash Function
- If the bucket already has a key-value pair, then iterating linearly until a empty bucket is found, and then insert the key-value pair
Delete key-value pair
- Obtain the Array index by passing the key to the Hash Function
- Iterating through linearly until the desired key-value pair is found
- Deleting the key-value pair by placing a special indicator in the bucket to denote the bucket is empty but it doesn’t break the iteration flow
Cons
Key-value pair clustering
When the array is filled up with key-value pairs in a continuous manner. We may need to iterate through many key-value pairs, including key-value pairs that has a hash index to get/delete the desired key-value pair