How does a hash table work and how are collisions resolved?

3 stars If you are short on time, start with this one.

In one or two sentences
A hash function turns a key into an array position, so lookup is O(1) on average. When different keys land on the same spot, chaining or open addressing resolves the collision.

Think of your own answer first

Say it out loud, or type it below. What you type never leaves this device.

Follow-up questions

These are likely next questions from an interviewer. Think of your answer first, then press the button.

  1. 1 / 3

    How do chaining and open addressing differ?

Sources checked

This is a textbook level concept, so no outside source is listed.