153k views
5 votes
Which of the following hash function classifies data into least number of buckets?

a. sum of digits modulo 8
b. sum of digits modulo 5
c. sum of digits modulo 2
d. sum of digits

1 Answer

3 votes

Final answer:

The correct answer is option c. sum of digits modulo 2. The sum of digits modulo 2, option c, is the hash function that classifies data into the least number of buckets, as it only sorts data into two possible categories: even or odd sums.

Step-by-step explanation:

This is because when a hash function is applied using modulo 2, it divides the range of data into two buckets. The result of any sum of digits modulo 2 will either be 0 (even sum) or 1 (odd sum). All other options provided, options a, b, and d, will create more buckets. For example, modulo 5 will divide data into 5 different buckets and modulo 8 into 8 buckets. Option d, sum of digits, doesn't limit the number of buckets at all; the number of buckets could be as large as the sum of the digits of the largest number in the dataset. Consequently, the modulo 2 hash function classifies data into the least number of buckets, making it the most efficient among the options provided for distributing data into the minimum categories.

This hash function will classify the data into only two buckets - 0 or 1. The sum of digits modulo 2 takes into account only the sum of the digits of the data and calculates the remainder when divided by 2.

For example, if the data is 123, the sum of the digits is 6. When we divide 6 by 2, the remainder is 0. Therefore, the data will be classified into bucket 0.

This hash function provides the fewest number of buckets compared to the other options, which classify the data into either 5, 8 or the number of buckets equal to the sum of the digits.

User Nobilis
by
9.0k points