Which goal best describes the primary purpose of a hash table?
7 Hash Tables Online Quiz Questions
Use this free practice quiz with 20 questions to review 7 Hash Tables, test your knowledge, and prepare for your next test or exam.
Which two statements about hashing and key equality are correct? Select all that apply.
- A
Equal keys must have equal hash values.
- B
Unequal keys can never have the same hash value.
- C
A collision-resolution strategy may be needed.
- D
A hash value alone proves that two keys are equal.
In open addressing, what is the technical name for a marker placed in a deleted slot so that later searches continue probing?
The collision-resolution strategy in which each bucket refers to a collection of entries is called .
Which two effects are generally associated with increasing a hash table's load factor? Select all that apply.
- A
It generally reduces lookup costs.
- B
It generally increases chain or probe lengths.
- C
It always makes the table use less memory overall.
- D
It can save space while making operations more expensive.
A separate-chaining table stores 15 entries in 20 buckets. What is its load factor? Enter the decimal value.
When a hash table grows to a larger array, it its existing entries because the bucket indices may change.
Which statement correctly describes resizing and insertion complexity when a hash table grows geometrically?
- A
One resize costs O(n), but geometric growth can make insertion O(1) amortized.
- B
Every insertion costs O(n) because the table may eventually resize.
- C
A resize costs O(1) because entries keep their old numerical indices.
- D
Geometric growth guarantees O(log n) worst-case insertion.
Deleting an entry from an open-addressed table by marking its slot completely empty can make a later search incorrectly report that another key is absent.
- A
True
- B
False
Explain when a hash table is a better choice than a balanced search tree, and when the balanced search tree is preferable. Contrast their relevant performance and ordering properties.
Which pair of disadvantages is specifically associated with separate chaining?
- A
It cannot store more entries than its number of buckets.
- B
It may incur pointer or allocation overhead and poorer cache locality.
- C
It requires a tombstone for every deletion.
- D
It guarantees that all searches take O(1) worst-case time.
A hash table uses separate chaining, and two different keys map to bucket 3. How are the two entries normally stored?
- A
Each colliding entry is discarded except the first
- B
All entries are stored in the bucket's chain
- C
Every collision immediately doubles the table
- D
The key is converted into a sorted-tree node
Which statement correctly describes the relationship between key equality and hashing?
- A
Unequal keys must always have different hash values
- B
Equal keys may have different hash values if their buckets match
- C
Equal keys must have equal hash values, while unequal keys may still collide
- D
A hash value alone proves that two keys are equal
A chained hash table contains 18 entries distributed across 6 buckets. What is its load factor α=mn?
- A
3
- B
31
- C
6
- D
24
Why does an open-addressed hash table commonly use a tombstone when deleting an entry?
- A
It permanently reserves the slot for the deleted key
- B
It causes every key in the table to be rehashed immediately
- C
It marks the slot as occupied by a new replacement entry
- D
It marks a deleted slot so probing continues during searches
A hash table grows from 4 buckets to 8 buckets and uses index=hash(key)modm. Why must existing entries be rehashed?
- A
The key values themselves must be changed to fit the new array
- B
The bucket index may change when the modulus changes
- C
Only entries involved in collisions need a new hash value
- D
Rehashing is needed only when the table shrinks
True or false: If a hash table doubles its capacity when a threshold is reached, insertion can be amortized O(1) even though one insertion that triggers resizing may cost O(n).
- A
True
- B
False
What term names the formation of long contiguous runs of occupied slots caused by linear probing?
What property should a key have while stored in a hash table so that its hash value and equality behavior do not change unexpectedly?
True or false: In an open-addressed hash table with m=10, the table can correctly support insertions at load factor α=1 as long as each probe sequence examines every slot.
- A
True
- B
False