The data structure used by a HashMap to store elements is a hash table.

Here's why:

  • Hashing: HashMaps use a hash function to calculate a unique hash code for each key. This hash code determines the index where the key-value pair will be stored in the hash table.
  • Collision Handling: Hash tables handle collisions (when two keys have the same hash code) using techniques like chaining or open addressing.

Therefore, the correct answer is B. Hash table.

HashMap Data Structure: How Elements Are Stored

原文地址: https://www.cveoy.top/t/topic/oerc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录