10 HASH TABLES Flashcards
What are hash tables?
Dynamic data structures optimized for insertions and lookups
Hash tables use mathematical functions to point us toward the data’s location, enabling quick retrieval of information.
What is the primary goal of using hash tables?
To find and retrieve information quickly
How do hash tables enable efficient retrieval?
By mapping target values directly to their indices using a hash function
What is a key in the context of data structures?
A single value stored with or derived from the data that can identify a record
Fill in the blank: Hash tables use __________ to compute a value’s index.
[hash functions]
What is a major downside of using an idealized data structure with an array bin for every possible key?
Excessive memory usage
What happens when two different keys map to the same hash value?
A collision occurs
What is the division method in hashing?
A simple hash function that computes the hash value using the formula f(k) = k % b
True or False: Hash functions can only map numeric keys.
False
What is chaining in hash tables?
An approach for handling collisions by storing a linked list in each bin
What is the purpose of a hash function?
To map keys into the hash table
What kind of data structures can use keys for organization?
- Sorted arrays
- Tries
- Hash tables
What is the primary challenge when using hash functions?
Handling collisions
Fill in the blank: A hash table’s structure may include an array of __________.
[ListNodes]
What does the term ‘hash value’ refer to?
The location in the hash table where a key is stored
How can we alleviate collisions in hash tables?
- Increasing the size of the hash table
- Choosing a better hash function
What does the modulo operation do in the context of hash functions?
It computes the remainder after division, determining the hash value
What is a potential problem with a simplistic hash function?
It may produce many collisions for certain key distributions
What is an example of a real-world application of hash tables?
Registration tables at events like conferences
True or False: Hash tables can store two different items in the same element of the array.
False
What does the ListNode structure in a hash table contain?
- key
- value
- next
What is the main limitation of using hash tables?
They are not a perfect solution for every problem
Fill in the blank: The hash function partitions keys into __________.
[disjoint sets]
What is a hash table using a linked list to store entries within the same bin?
A data structure that uses linked lists to handle collisions by chaining multiple entries that hash to the same bin.