Basis Lab

Finding It Instantly

How Full Is Too Full

Last timeWhen Two Keys Collide

The cost of a lookup depends on one number: how full the table is. Keeping that number low means rebuilding the table bigger before it fills, and the rebuild is cheaper than it looks.

Everything in the last lesson came down to one number: how full the table is.

That number is not given by the problem. It is chosen, and it is maintained.

FIG 1Slots examined for a search that finds nothing
0.0062.50125.00187.50250.000.10.30.50.70.9fullness, items divided by positions
chainingprobing along, with clustering
The straight line is chaining and it barely moves. The other is probing, and it is the reason thresholds exist: about two and a half slots at half full, eight and a half at three quarters, fifty at nine tenths. The useful reading is not that probing is bad but that it is excellent up to a point and then not, so the whole design question is where to stand on the flat part. Notice also what is absent from both curves: the size of the table. A thousand positions and a thousand million positions at the same fullness cost the same, which is the actual content of the claim that a lookup is instant.

The curve the choice is made from

The flat part runs out somewhere around two thirds. That is where the table

is grown, and real libraries use thresholds in that region.

The lesson stops here

1 more paragraph to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01Finding One Thing Among Many
  2. 02Turning a Key Into an Addressopening only
  3. 03When Two Keys Collideopening only
  4. 04How Full Is Too Fullyou are here
  5. 05What Makes a Hash Function Goodopening only
  6. 06Asking Only Whether It Is Thereopening only
  7. 07What a Hash Table Cannot Doopening only
  8. 08The Same Trick Everywhere Elseopening only

Read alongside