Skip to main contentSkip to solution

How many comparisons does the hash based search technique requires to find the key (in ideal scenario)?

Solution

✅ Correct Option: 3

In an ideal hash table, the hash function maps the key straight to its index, so the key is reached directly and only one comparison is needed to confirm it. With no collisions, search takes constant time, O(1)O(1).


Option 1: nn comparisons is linear search in the worst case, where every element may be checked.

Real hash tables need more than one comparison when collisions occur, and the cost grows with the length of the chain or probe sequence. The ideal case assumes none.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question