Free Practice Quiz Question List

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.

20 questions
01
Choose one
1 point

Which goal best describes the primary purpose of a hash table?

  1. A

    It maintains all keys in sorted order.

  2. B

    It locates keys quickly using hashing.

  3. C

    It guarantees logarithmic worst-case lookup.

  4. D

    It eliminates the need for key equality checks.

02
Choose all
1 point

Which two statements about hashing and key equality are correct? Select all that apply.

  1. A

    Equal keys must have equal hash values.

  2. B

    Unequal keys can never have the same hash value.

  3. C

    A collision-resolution strategy may be needed.

  4. D

    A hash value alone proves that two keys are equal.

03
Written response
1 point

In open addressing, what is the technical name for a marker placed in a deleted slot so that later searches continue probing?

04
Fill in the blank
1 point

The collision-resolution strategy in which each bucket refers to a collection of entries is called .

05
Choose all
1 point

Which two effects are generally associated with increasing a hash table's load factor? Select all that apply.

  1. A

    It generally reduces lookup costs.

  2. B

    It generally increases chain or probe lengths.

  3. C

    It always makes the table use less memory overall.

  4. D

    It can save space while making operations more expensive.

06
Written response
1 point

A separate-chaining table stores 15 entries in 20 buckets. What is its load factor? Enter the decimal value.

07
Fill in the blank
1 point

When a hash table grows to a larger array, it its existing entries because the bucket indices may change.

08
Choose one
1 point

Which statement correctly describes resizing and insertion complexity when a hash table grows geometrically?

  1. A

    One resize costs O(n), but geometric growth can make insertion O(1) amortized.

  2. B

    Every insertion costs O(n) because the table may eventually resize.

  3. C

    A resize costs O(1) because entries keep their old numerical indices.

  4. D

    Geometric growth guarantees O(log n) worst-case insertion.

09
True or false
1 point

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.

  1. A

    True

  2. B

    False

10
Open ended
1 point

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.

11
Choose one
1 point

Which pair of disadvantages is specifically associated with separate chaining?

  1. A

    It cannot store more entries than its number of buckets.

  2. B

    It may incur pointer or allocation overhead and poorer cache locality.

  3. C

    It requires a tombstone for every deletion.

  4. D

    It guarantees that all searches take O(1) worst-case time.

12
Choose one
1 point

A hash table uses separate chaining, and two different keys map to bucket 3. How are the two entries normally stored?

  1. A

    Each colliding entry is discarded except the first

  2. B

    All entries are stored in the bucket's chain

  3. C

    Every collision immediately doubles the table

  4. D

    The key is converted into a sorted-tree node

13
Choose one
1 point

Which statement correctly describes the relationship between key equality and hashing?

  1. A

    Unequal keys must always have different hash values

  2. B

    Equal keys may have different hash values if their buckets match

  3. C

    Equal keys must have equal hash values, while unequal keys may still collide

  4. D

    A hash value alone proves that two keys are equal

14
Choose one
1 point

A chained hash table contains 18 entries distributed across 6 buckets. What is its load factor α=nm\alpha = \frac{n}{m}?

  1. A

    3

  2. B

    13\frac{1}{3}

  3. C

    6

  4. D

    24

15
Choose one
1 point

Why does an open-addressed hash table commonly use a tombstone when deleting an entry?

  1. A

    It permanently reserves the slot for the deleted key

  2. B

    It causes every key in the table to be rehashed immediately

  3. C

    It marks the slot as occupied by a new replacement entry

  4. D

    It marks a deleted slot so probing continues during searches

16
Choose one
1 point

A hash table grows from 4 buckets to 8 buckets and uses index=hash(key) mod mindex = hash(key) \bmod m. Why must existing entries be rehashed?

  1. A

    The key values themselves must be changed to fit the new array

  2. B

    The bucket index may change when the modulus changes

  3. C

    Only entries involved in collisions need a new hash value

  4. D

    Rehashing is needed only when the table shrinks

17
True or false
1 point

True or false: If a hash table doubles its capacity when a threshold is reached, insertion can be amortized O(1)O(1) even though one insertion that triggers resizing may cost O(n)O(n).

  1. A

    True

  2. B

    False

18
Written response
1 point

What term names the formation of long contiguous runs of occupied slots caused by linear probing?

19
Written response
1 point

What property should a key have while stored in a hash table so that its hash value and equality behavior do not change unexpectedly?

20
True or false
1 point

True or false: In an open-addressed hash table with m=10m=10, the table can correctly support insertions at load factor α=1\alpha=1 as long as each probe sequence examines every slot.

  1. A

    True

  2. B

    False