Question:

Which of the statement(s) is/are True for the given question.
Data elements are: 7, 5, 17, 13, 9, 27, 31, 25, 35.
Hash Table Size: 7
Hash Function: H(I) = (Data element) mod (Hash Table Size)
Options:
(A) Element 27 will create collision.
(B) Element 25 will create collision.
(C) Element 35 will create collision.
(D) Element 31 will create collision.
Choose the correct answer from the options given below:

Updated On: May 28, 2025
  • (A), (B), and (C) only
  • (A), (C), and (D) only
  • (B), (C), and (D) only
  • (A), and (D) only
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Approach Solution - 1

To determine which elements will create a collision in the hash table, we need to compute the hash function for each data element. The hash function given is: H(I) = (Data element) mod (Hash Table Size).
1. Calculate hash values for each element:
  • 7: \(7 \mod 7 = 0\)
  • 5: \(5 \mod 7 = 5\)
  • 17: \(17 \mod 7 = 3\)
  • 13: \(13 \mod 7 = 6\)
  • 9: \(9 \mod 7 = 2\)
  • 27: \(27 \mod 7 = 6\)
  • 31: \(31 \mod 7 = 3\)
  • 25: \(25 \mod 7 = 4\)
  • 35: \(35 \mod 7 = 0\)
2. Identify collisions:
  • Element 27 causes a collision with 13 as both have hash index 6.
  • Element 31 causes a collision with 17 as both have hash index 3.
  • Element 35 causes a collision with 7 as both have hash index 0.
  • There is no collision for element 25 as it has a unique hash index 4.
3. Conclusion:
The statements for elements causing collisions are:
  • (A) Element 27 will create collision.
  • (C) Element 35 will create collision.
  • (D) Element 31 will create collision.
Therefore, the correct answer is: (A), (C), and (D) only.
Was this answer helpful?
0
0
Hide Solution
collegedunia
Verified By Collegedunia

Approach Solution -2

The correct statements are (A), (C), and (D) only.

Additional Context:

  • Hash Calculations:
    • H(7)=0, H(5)=5, H(17)=3, H(13)=6, H(9)=2
    • H(27)=6 (collides with 13 at index 6) → (A) True
    • H(31)=3 (collides with 17 at index 3) → (D) True
    • H(25)=4 (no collision) → (B) False
    • H(35)=0 (collides with 7 at index 0) → (C) True
  • Collision Resolution:
    • Common methods: Chaining, Open addressing
    • Load factor = n/table_size = 9/7 ≈ 1.29 (high collision probability)
  • Hash Table Visualization:
    Index  Elements
    0     [7, 35]
    1     []
    2     [9]
    3     [17, 31]
    4     [25]
    5     [5]
    6     [13, 27]
        

Correct Answer: (2) (A), (C), and (D) only.

Was this answer helpful?
0
0