Free Practice Quiz Question List

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.

20 questions
01
Choose one
1 point

A hash table has 10 slots and uses the hash function h(k)=kh(k)=k. To which slot is key 42 initially directed?

  1. A

    4

  2. B

    2

  3. C

    0

  4. D

    10

02
True or false
1 point

True or false: In a separate-chaining hash table, the load factor may be greater than 1.

  1. A

    True

  2. B

    False

03
Choose one
1 point

Which statement best distinguishes an ordinary hash function used in a data structure from a cryptographic hash?

  1. A

    A data-structure hash must make it computationally difficult to recover the input.

  2. B

    A data-structure hash should be fast and distribute unrelated keys well.

  3. C

    A data-structure hash must always produce a unique index for every key.

  4. D

    A data-structure hash must use a second hash function for collision resolution.

04
Written response
1 point

A separate-chaining table contains 5 entries in 5 buckets. What is its load factor α\alpha?

05
Fill in the blank
1 point

A collision occurs when map to .

06
Choose one
1 point

Why must the load factor of an open-addressing hash table remain below 1?

  1. A

    It may exceed 1 because colliding entries are stored in chains.

  2. B

    It must equal 1 so that every slot is used.

  3. C

    It must remain below 1 so at least one slot is empty and an unsuccessful search can terminate.

  4. D

    It must remain below 0.5 to prevent all collisions.

07
Choose all
1 point

Select all properties that a useful hash function for a hash table should have.

  1. A

    The same key produces the same hash value during a table operation.

  2. B

    Computing the hash is fast.

  3. C

    Unrelated keys tend to spread across the table rather than cluster.

  4. D

    Equal keys produce the same hash value.

08
True or false
1 point

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.

  1. A

    True

  2. B

    False

09
Written response
1 point

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?

10
Fill in the blank
1 point

During resizing, each entry's index must be . Moving all entries for one resize takes time.

11
Choose all
1 point

Under which conditions can hash-table search and update operations have expected O(1)O(1) time? Select all correct choices.

  1. A

    The hash function distributes keys well.

  2. B

    The load factor is controlled.

  3. C

    Keys remain sorted in the table.

  4. D

    The collision strategy does not create excessive clustering.

12
Open ended
1 point

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.

13
Choose one
1 point

What problem occurs when linear probing creates long consecutive runs of occupied slots?

  1. A

    Secondary hashing

  2. B

    Primary clustering

  3. C

    Chain overflow

  4. D

    Index compression

14
True or false
1 point

True or false: If two keys have the same hash value, the keys must be equal.

  1. A

    True

  2. B

    False

15
Choose one
1 point

Why must a hash table rehash its entries after its capacity changes?

  1. A

    To sort all keys before lookup

  2. B

    To eliminate the need for equality checks

  3. C

    To place entries according to indexes based on the new capacity

  4. D

    To guarantee that no two keys will ever collide

16
Choose one
1 point

Which statement best describes a separate-chaining hash table?

  1. A

    It cannot store more entries than there are slots.

  2. B

    It can store more entries than there are slots.

  3. C

    It requires the load factor to remain below 1.

  4. D

    It stores every entry in a different slot.

17
Choose one
1 point

A hash table has capacity 8 and a resize threshold of 0.750.75. When is resizing most appropriately triggered according to the example in the material?

  1. A

    It resizes after the sixth entry only if the table is empty.

  2. B

    It resizes when the table reaches exactly seven total entries, before the seventh insertion.

  3. C

    It may resize when the seventh entry is inserted.

  4. D

    It never needs to resize because the threshold is below 1.

18
Choose one
1 point

What is a principal performance drawback of linear probing?

  1. A

    It prevents all collisions by assigning a unique hash value to every key.

  2. B

    It can create primary clustering as consecutive occupied slots form long runs.

  3. C

    It requires a separate linked list for every occupied slot.

  4. D

    It guarantees O(1)O(1) worst-case lookup time.

19
Written response
1 point

A table has 10 slots and uses h(k)=kh(k)=k. What index is produced for key 42 by index⁡(k)=h(k) mod 10\operatorname{index}(k)=h(k)\bmod 10?

20
Written response
1 point

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?