In a hash table, the load factor primarily represents which of the following?

2024

In a hash table, the load factor primarily represents which of the following?

  1. A.

    Number of collisions per bucket

  2. B.

    Ratio of stored elements to the total number of slots

  3. C.

    Number of hash functions used

  4. D.

    Total memory occupied by the hash table

  5. E.

    Maximum size of a hash key

Attempted by 49 students.

Show answer & explanation

Correct answer: B

The load factor (denoted alpha) of a hash table measures how full the table is. It is defined as alpha = n / m, where n is the number of entries (keys) currently stored and m is the total number of slots (buckets) in the table.

Therefore the load factor is the ratio of the number of stored elements to the total number of slots. It does not count collisions, hash functions, memory bytes, or key sizes; it is purely a fill ratio.

The load factor matters because it controls performance. As alpha grows, collisions become more likely and average lookup, insert, and delete times rise. For separate chaining the average chain length equals alpha, while open addressing requires alpha < 1 (each slot holds one item) and degrades sharply as alpha approaches 1.

To keep operations close to O(1) on average, implementations rehash (grow the table and redistribute keys) once the load factor exceeds a chosen threshold, commonly around 0.75 for open addressing.

Hence the correct description is: the ratio of stored elements to the total number of slots.

Explore the full course: Niacl Ao It Specialist