Computer Science I / Functions
Practice question · Multiple choice

A hash function maps a large key space into a small one, so collisions are guaranteed. Which mathematical fact makes that inevitable?

Hints
  1. Count the possible strings and the available buckets. Which is larger?
  2. Ask whether any function from a larger set to a smaller one could be injective.
Show the answer

C. The pigeonhole principle, more keys than buckets

Why

Infinitely many possible strings and finitely many buckets means no function can be injective, collisions are a theorem, not a defect. That is why every hash table ships with a resolution strategy, and why the design goal is spreading keys evenly rather than the impossible one of avoiding collisions.

Read the lesson: Functions →

Practise Functions

The app has 4 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Functions