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.


Bucket index

Number of records

0

3

1

2

2

2

3

1

4

0


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.

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: