In hash file organisation, what could the bucket size be if a single collision immediately causes an overflow (collision and overlapping occur at the same time)?

Difficulty: Medium

Correct Answer: 1

Explanation:


Introduction / Context:
Hash file organisation is a common technique for storing records in files so that they can be accessed quickly by a hash key. Records are placed into buckets according to the value of a hash function. The capacity of each bucket, often expressed as the bucket size, determines how many records can be stored before an overflow occurs. This question focuses on an extreme case where every collision directly results in an overflow condition, and it asks you to infer the bucket size from that description.


Given Data / Assumptions:

  • We have a hash file organisation with buckets of some fixed capacity.
  • A collision means that two different records hash to the same bucket address.
  • Overlapping or overflow means that the bucket cannot hold additional records and some overflow handling technique is triggered.
  • The question states that collision and overflow happen at the same time whenever a second record hashes to the same bucket.


Concept / Approach:
In a hash file, bucket size determines how many records can be stored in a bucket before overflows appear. If bucket size is greater than one, then a collision, which is simply two keys hashing to the same bucket, does not automatically cause overflow because both records can fit inside the bucket. Overflow will occur only when the bucket capacity is exceeded. If, however, every collision immediately produces an overflow, it must be the case that the bucket cannot hold more than one record. In that situation, the very first record occupies the single slot in the bucket, and the second record that collides will not fit and must go to an overflow area.


Step-by-Step Solution:
Step 1: Define bucket size as the number of records that a bucket can hold without overflow. Step 2: Consider bucket size equal to 2. The first record occupies one slot, the second record that hashes to the same bucket occupies the second slot, so collision does not cause immediate overflow yet. Step 3: Consider bucket size equal to 4. The first few collisions can be absorbed, and overflow would only occur after four records hash to the same bucket. Step 4: Consider bucket size equal to 1. The very first record uses the only available slot in the bucket. Step 5: When a second record hashes to the same bucket, a collision occurs and there is no free slot, so overflow happens at the same moment as the collision. Therefore the bucket size must be 1.


Verification / Alternative check:
Another way to verify is to think about the definition of collision and overflow. Collision simply means that two or more keys map to the same hash address. Overflow occurs when the bucket cannot store all of those records. For collision and overflow to always coincide on the second record, the bucket must become full as soon as the first record is inserted. This is only possible when the bucket capacity is exactly one record. Any larger bucket capacity would allow at least one collision to occur without overflow, contradicting the condition stated in the question.


Why Other Options Are Wrong:
Option 2: With bucket size 2, the first two colliding records fit into the bucket, so collision does not necessarily imply immediate overflow. Option 0: A bucket size of zero is not meaningful in practice because it would not allow any records to be stored and is not a standard assumption in hash file design. Option 4: With bucket size 4, multiple collisions can occur before any overflow happens, so collision and overflow do not occur at the same time.


Common Pitfalls:
A frequent misunderstanding is to assume that any collision in a hash table automatically means overflow or a problem, which is not true when buckets can hold multiple records or when open addressing is used. Another pitfall is to overlook that the question describes a very specific scenario where overflow always coincides with collision, which forces a minimal capacity interpretation. Carefully reading such qualifiers in exam questions is essential to avoid choosing a plausible but incorrect bucket size.


Final Answer:
If collision and overflow always occur at the same time in hash file organisation, the bucket size must be 1.

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion