Spreading rebuild costs across insertions

A small in-memory index begins with an empty hash table of capacity 4. It inserts 18 distinct records, one at a time. Immediately before an insertion would make the number of entries exceed capacity, the table doubles its capacity and places every existing entry into the new table exactly once. It then places the incoming record once.


Every placement of a new or existing entry costs one work unit. Count entry placements only; this model assigns no additional work units to allocation, bucket initialization, or key comparisons.


Find the total work spent placing existing entries during rebuilds, the largest work charged to any single insertion including its triggered rebuild, and the average total work per insertion across all 18 insertions. Give the first two answers as whole work units and the average in work units per insertion to two decimal places.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Hash Tables Questions: