Quiz 2

Pigeonhole Principle and Inclusion-Exclusion

364 words
2 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Pigeonhole Principle and Inclusion-Exclusion ## 2.1 Pigeonhole Principle **Simple form:** If $n$ items are placed into $m$ boxes and $n > m$, then at least one box contains at least 2 items. **Generalized form:** If $n$ items are placed into $m$ boxes, then at least one box contains at least $\lceil n/m \rceil$ it...

Pigeonhole Principle and Inclusion-Exclusion

2.1 Pigeonhole Principle

Simple form: If nn items are placed into mm boxes and n>mn > m, then at least one box contains at least 2 items. Generalized form: If nn items are placed into mm boxes, then at least one box contains at least n/m\lceil n/m \rceil items.

Applications

Example 1: Among any 13 people, at least 2 share the same birth month. (13>1213 > 12) Example 2: In any set of 5 points in a 2×22 \times 2 square, some pair are within 2\sqrt{2} distance. (Divide into 4 unit squares; by pigeonhole, 2 points in same square, max distance = 2\sqrt{2}.) Example 3: Any subset of size 6 from {1,2,,9}\{1,2,\dots,9\} contains two numbers summing to 10. (Pairs: {1,9},{2,8},{3,7},{4,6},{5}\{1,9\},\{2,8\},\{3,7\},\{4,6\},\{5\}; 5 pigeonholes, 6 pigeons.)

2.2 Inclusion-Exclusion Principle

For two sets: AB=A+BAB|A \cup B| = |A| + |B| - |A \cap B| For three sets: ABC=A+B+CABACBC+ABC|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|

General Formula

i=1nAi=iAii<jAiAj+i<j<kAiAjAk\left|\bigcup_{i=1}^n A_i\right| = \sum_{i} |A_i| - \sum_{i<j} |A_i \cap A_j| + \sum_{i<j<k} |A_i \cap A_j \cap A_k| - \cdots

Example: Derangements

Number of permutations of nn elements with no fixed point:
Dn=n!k=0n(1)kk!D_n = n! \sum_{k=0}^n \frac{(-1)^k}{k!}
For n=4n=4: D4=4!(10!11!+12!13!+14!)=24(11+1216+124)=9D_4 = 4!(\frac{1}{0!} - \frac{1}{1!} + \frac{1}{2!} - \frac{1}{3!} + \frac{1}{4!}) = 24(1-1+\frac{1}{2}-\frac{1}{6}+\frac{1}{24}) = 9.

✅ Practice Questions

Q1: How many integers from 1 to 100 are divisible by 2 or 3?
Solution
A=100/2=50|A| = \lfloor 100/2 \rfloor = 50 (divisible by 2) B=100/3=33|B| = \lfloor 100/3 \rfloor = 33 (divisible by 3) AB=100/6=16|A \cap B| = \lfloor 100/6 \rfloor = 16 (divisible by 6) AB=50+3316=67|A \cup B| = 50 + 33 - 16 = 67 Q2: Prove that among any n+1n+1 integers from {1,,2n}\{1,\dots,2n\}, one divides another. Solution
Write each number as 2k×m2^k \times m where mm is odd. There are only nn odd numbers in {1,,2n}\{1,\dots,2n\}. By pigeonhole, two numbers share the same odd part; the smaller divides the larger. Join Discord PreviousAdvanced PermutationsNextRecurrence Relations
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.