114k views
0 votes
Specify the correct statement about hashing algorithm (Select the best answer).

[A]If the coalesced method is used for colision resolution, insertion and searching (and sometimes deletion) always take constant time: O(1)
[B]The expected complexity of hashing algorithm is O(1). However by the collision resolution, sometimes it may take O(n)
[C]If the chaining method is used for collision resolution, insertion and searching (and sometimes deletion) can take constant time: O(1)
[D]No matter how many data items there are, insertion and searching (and sometimes deletion) always take constant time: O(1)

User Wagh
by
8.1k points

1 Answer

4 votes

Final answer:

The correct statement regarding hashing algorithms is that they generally have an expected time complexity of O(1), but due to collisions and their resolutions, they can occasionally result in time complexity of O(n).

Step-by-step explanation:

The correct statement about hashing algorithms is [B]The expected complexity of hashing algorithm is O(1). However, by the collision resolution, sometimes it may take O(n). While hashing algorithms aim for constant time complexity for insertion, searching, and sometimes deletion operations, there are cases when collisions occur, which can increase the time complexity. The linear increase in time complexity can happen with certain collision resolution techniques like linear probing, where continuous positions are checked for a free slot, or in chained hashing if the linked lists become too long.

User Tomas Kulich
by
8.0k points