A hash table has 10 slots and uses the hash function . To which slot is key 42 initially directed?
06 Hash Tables Online Quiz Questions
Use this free practice quiz with 20 questions to review 06 Hash Tables, test your knowledge, and prepare for your next test or exam.
True or false: In a separate-chaining hash table, the load factor may be greater than 1.
- A
True
- B
False
Which statement best distinguishes an ordinary hash function used in a data structure from a cryptographic hash?
- A
A data-structure hash must make it computationally difficult to recover the input.
- B
A data-structure hash should be fast and distribute unrelated keys well.
- C
A data-structure hash must always produce a unique index for every key.
- D
A data-structure hash must use a second hash function for collision resolution.
A separate-chaining table contains 5 entries in 5 buckets. What is its load factor α?
A collision occurs when map to .
Why must the load factor of an open-addressing hash table remain below 1?
- A
It may exceed 1 because colliding entries are stored in chains.
- B
It must equal 1 so that every slot is used.
- C
It must remain below 1 so at least one slot is empty and an unsuccessful search can terminate.
- D
It must remain below 0.5 to prevent all collisions.
Select all properties that a useful hash function for a hash table should have.
- A
The same key produces the same hash value during a table operation.
- B
Computing the hash is fast.
- C
Unrelated keys tend to spread across the table rather than cluster.
- D
Equal keys produce the same hash value.
True or false: In open addressing, simply clearing a deleted entry's slot is always safe because a later search can begin again from the key's initial hash index.
- A
True
- B
False
What is the name of the collision-resolution strategy in which each table slot refers to a collection of entries that hash to that slot?
During resizing, each entry's index must be . Moving all entries for one resize takes time.
Under which conditions can hash-table search and update operations have expected O(1) time? Select all correct choices.
- A
The hash function distributes keys well.
- B
The load factor is controlled.
- C
Keys remain sorted in the table.
- D
The collision strategy does not create excessive clustering.
Compare separate chaining with open addressing as collision-resolution strategies. Explain how they differ in storage layout, load-factor constraints, deletion, and at least one performance or memory trade-off.
What problem occurs when linear probing creates long consecutive runs of occupied slots?
- A
Secondary hashing
- B
Primary clustering
- C
Chain overflow
- D
Index compression
True or false: If two keys have the same hash value, the keys must be equal.
- A
True
- B
False
Why must a hash table rehash its entries after its capacity changes?
- A
To sort all keys before lookup
- B
To eliminate the need for equality checks
- C
To place entries according to indexes based on the new capacity
- D
To guarantee that no two keys will ever collide
Which statement best describes a separate-chaining hash table?
- A
It cannot store more entries than there are slots.
- B
It can store more entries than there are slots.
- C
It requires the load factor to remain below 1.
- D
It stores every entry in a different slot.
A hash table has capacity 8 and a resize threshold of 0.75. When is resizing most appropriately triggered according to the example in the material?
- A
It resizes after the sixth entry only if the table is empty.
- B
It resizes when the table reaches exactly seven total entries, before the seventh insertion.
- C
It may resize when the seventh entry is inserted.
- D
It never needs to resize because the threshold is below 1.
What is a principal performance drawback of linear probing?
- A
It prevents all collisions by assigning a unique hash value to every key.
- B
It can create primary clustering as consecutive occupied slots form long runs.
- C
It requires a separate linked list for every occupied slot.
- D
It guarantees O(1) worst-case lookup time.
A table has 10 slots and uses h(k)=k. What index is produced for key 42 by index(k)=h(k)mod10?
A compiler symbol table must support fast lookup of a variable's information by its exact name, but it does not need sorted traversal, minimum or maximum queries, or predecessor and successor queries. Which data structure is the most appropriate choice?