LearnViz CompSci
Home / Learn / Theory & Discrete Math / Pigeonhole Principle

Beginner Topic 9 of 51 Theory & Discrete Math

Pigeonhole Principle

If more items than boxes, some box holds two.

How it works

The pigeonhole principle states that if more than n items are placed into n containers, at least one container holds at least two items. The generalized form says that with m items in n boxes, some box has at least the ceiling of m/n items. It is simple but powerful for proving that something must exist without constructing it.

Step-by-step walkthrough

  1. Place 4 pigeons in 3 boxes.
  2. Three pigeons fill one box each.
  3. The fourth must share a box.
  4. So some box holds at least two.
  5. It proves that two people in a city of 1000 must share the same number of hairs.

Where it is used

It proves that in any group of 367 people two share a birthday, that any compression algorithm cannot shrink all inputs, that hash collisions are unavoidable and that any sequence of n squared plus 1 distinct numbers has a monotone subsequence of length n plus 1.

Common pitfall

The difficulty lies in identifying the right pigeons and holes, which requires creativity. It shows existence only, not which box or items. Miscounting the number of holes gives weak or false conclusions. Define items and categories carefully, and check whether the generalized version gives a stronger bound.

Where it fits in the course

Pigeonhole Principle is topic 9 of 51 in Theory & Discrete Math, rated Beginner. It follows Permutations and Combinations. The next topic is Recurrence Relations.

Practice and explore

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the Theory & Discrete Math quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is Pigeonhole Principle?
If more items than boxes, some box holds two. It belongs to Theory & Discrete Math and is a beginner-level topic.
Where do people use Pigeonhole Principle?
It proves that in any group of 367 people two share a birthday, that any compression algorithm cannot shrink all inputs, that hash collisions are unavoidable and that any sequence of n squared plus 1 distinct numbers has a monotone subsequence of length n plus 1.
What is the most common mistake with Pigeonhole Principle?
The difficulty lies in identifying the right pigeons and holes, which requires creativity.
What should I learn before this topic?
Start with Permutations and Combinations, the topic just before it in Theory & Discrete Math.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Theory & Discrete Math quiz.
Is Pigeonhole Principle hard to learn?
It is a Beginner topic, so it works as an entry point. If the terms are new, read the explanation twice and try the visualizer before the quiz.
How long does it take to learn Pigeonhole Principle?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Pigeonhole Principle?
Permutations and Combinations, Recurrence Relations, Counting Principles are closely connected. The full list is in the related topics section of this page.
What should I study after Pigeonhole Principle?
Continue with Recurrence Relations, the next topic in Theory & Discrete Math.

Related topics