Two hash tables each store 120 distinct records in 60 buckets. Each bucket holds a list searched sequentially from its first record. Table A has exactly two records in every bucket. Table B has all 120 records in one bucket and no records in the other buckets.
For successful lookups, each stored key is equally likely to be requested. Count only comparisons with stored keys. Which statements are true? Select all that apply.
Equal load factors guarantee at most two comparisons for any successful lookup.
Both tables have load factor 2, despite having different successful-search costs.
Table B averages 60.5 key comparisons per successful lookup under these assumptions.
Resizing Table B to 120 buckets guarantees no list exceeds 60 records.
Unlock full course notes by signing up
Average lookup costs in bucket lists
A session cache uses a hash table with five buckets. Each bucket stores a list searched from its first record onward. The current list lengths are shown below.
For successful lookups, each stored key is equally likely to be requested. For unsuccessful lookups, the requested key is absent and each bucket is equally likely to be selected. A successful search stops at the matching record; an unsuccessful search checks the entire selected list.
Find the average number of key comparisons for a successful lookup and for an unsuccessful lookup. Count only comparisons with stored keys. Give both answers in comparisons per lookup, to three decimal places.
Accounting for rebuild work
A hash table's capacity is its number of buckets. During a rebuild, this implementation creates a fresh bucket array and redistributes all stored entries into it.
Initializing each new bucket costs one work unit. Redistributing each stored entry costs one additional work unit, including determining its destination. Count only these two kinds of work; each row describes an independent rebuild with no entries added or removed.
Complete the initialization work, redistribution work, and total work for each row. Enter exact integers in work units.
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.