Skip to main contentSkip to solution

What does HASHING function do?

Solution

✅ Correct Option: 2

A hash function takes a key and applies a formula to it, such as h(k)=k mod mh(k) = k \bmod m, to calculate the position (index) in the hash table where the key is stored or searched. This gives direct access to the key without scanning the list, so search takes O(1)O(1) time on average.


Option 1: this describes linear search, which checks elements one by one.

Option 3: this describes searching in a sorted list, as in binary search, which uses comparisons and not a formula.

Option 4: mapping different keys to the same slot is a collision, which is an undesirable outcome that a good hash function tries to minimise, not what it is meant to do.

Keyboard Shortcuts

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