📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!

  • google app store apple app store
  • ✖

      Question

      What is a 'Hash Table' and how does it handle 'collisions'?

      A A sorted array with binary search capability; collisions are handled by resorting Correct Answer Incorrect Answer
      B A data structure that maps keys to values using a hash function; collisions are handled by chaining or open addressing Correct Answer Incorrect Answer
      C A type of binary tree that balances itself when collisions occur Correct Answer Incorrect Answer
      D A table that stores hash values of encrypted passwords; collisions trigger re-encryption Correct Answer Incorrect Answer
      E A network routing table; collisions are resolved by load balancing Correct Answer Incorrect Answer

      Solution

      Hash function converts a key (e.g., AccountNumber) to an array index. Average O(1) for insert, delete, search  and it degrades to O(n) for worst case with many collisions. Collision resolution is done by Chaining in which each bucket holds a linked list of all keys mapping to that index (simple, handles high load factors). Open Addressing means on collision, probe for the next available slot (linear probing, quadratic probing, double hashing). Load factor (n/m) determines performance. Hash tables power Python dictionaries, Java HashMaps, database join operations, and caching systems.

      Practice Next

      Relevant for Exams:

      ask-question