Hash Tables
- Adding an element: simple extension of the algorithm for finding an object
- Compute the hash code to locate the bucket in which the element should be inserted
- Try finding the object in that bucket
- If it is already present, do nothing; otherwise, insert it
- Removing an element is equally simple
- Compute the hash code to locate the bucket in which the element should be inserted
- Try finding the object in that bucket
- If it is present, remove it; otherwise, do nothing
- If there are few collisions, adding or removing takes O(1) time