Discrete Math for Data Science

DSCI 220, 2025 W1

November 19, 2025

Announcements

Warm-Up 1

 

You have a drawer with:

  • 6 heart socks ❤️
  • 8 cat socks 😺
  • 5 striped socks 🌈

You pull out socks in the dark, one at a time.

Question: How many socks do you need to pull to guarantee you have a matching pair?

Thinking About the Worst Case

Worst-case sequence:

  1. heart
  2. cat
  3. striped

 

At this point: no pair yet

 

So the next sock must match something.

Warm-Up 2

Question:
How many subsets does an \(n\)-element set have?

Try small cases:

  • \(n = 0\): \(1\) subset
  • \(n = 1\): \(2\) subsets
  • \(n = 2\): \(4\) subsets
  • \(n = 3\): \(8\) subsets

Conjecture:
\[ |P(S)| = 2^n \]

Why Might This Be True?

Let \(S\) be an \(n\)-element set.

Choose an element \(a \in S\).

Every subset of \(S\) either:

  1. Includes \(a\)
  2. Does NOT include \(a\)

Include or Exclude \(a\)

Subsets split by including or excluding a Visualizing all subsets of S as two groups: those that do not contain a, and those that do contain a. S − {a} (n − 1 elements) all subsets of S − {a} Subsets WITHOUT a exactly the subsets of S − {a} Subsets WITH a take a subset of S − {a} and add a use subset as-is subset ∪ {a}

So:

\[ |P(S)| = |P(S - \{a\})| + |P(S - \{a\})| = 2\cdot |P(S - \{a\})| \]

Proof by Induction

Claim: For any set \(S\) with \(|S|=n\), \[ |P(S)| = 2^n \]

Base Case: \(n = 0\)

A 0-element set has exactly one subset: \(\{\}\)

And the claim says we should have \(2^0 = 1\).

 

Inductive Step

Assume that for any \(j<n\), if \(|T|= j\), \(|P(T)| = 2^{j}\)

Then from previous slide:

\[ |P(S)| = 2\cdot |P(S - \{a\})| \]

A Teaser…

  1. Dividing up the things you’re counting into categories can help!

  2. When you split objects into categories

    • If you have more objects than categories, then some category must contain at least two objects.

Pigeonhole Principle

Warm-Up: Tennis Balls

 

29 tennis balls are distributed among 4 players.


Claim:
Some player must receive more than 7 balls.

A Picture of the Situation

Player 1 Player 2 Player 3 Player 4

Proving Your Intuition

Suppose, for the sake of contradiction, that no player gets more than 7 balls.

Then the maximum total number of balls is:

The Pigeonhole Principle

 

Simple form:

If more than \(n\) objects are placed into \(n\) boxes,
then there is a box containing at least 2 objects.

 

General form:

If \(N\) objects are placed into \(k\) boxes,
then there is a box containing at least

________ objects.

Tennis Balls as an Example

29 tennis balls, 4 players.

  • Objects = 29 balls
  • Boxes = 4 players
  • So some player has at least \[ \left\lceil \frac{29}{4} \right\rceil = \left\lceil 7.25 \right\rceil = 8 \] balls.

Another Example

 

Claim: Among any 7 positive integers,there are 2 whose sum or difference is divisible by 10.

 

What are the pigeons?

What are the boxes?

Last Digits and Remainders

Every positive integer has a last digit (i.e., a remainder when divided by 10):

\[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 \]

We want to detect when a sum or difference is divisible by 10.

  • Difference divisible by 10: numbers have the same last digit
  • Sum divisible by 10: last digits add to 10:
    • (1, 9), (2, 8), (3, 7), (4, 6), and also (0, 0), (5, 5)

Defining the Boxes

Group integers by their last digit:

A last digit 0 B last digit 5 C last digit 1 or 9 D last digit 2 or 8 E last digit 3 or 7 F last digit 4 or 6

Place all the elements from either one of the following sets into the boxes.

  • \(\{13, 15, 28, 30, 1, 46, 58\}\)
  • \(\{27, 86, 50, 35, 11, 44, 108\}\)

Does the conjecture appear to be true?

PHP

We have:

  • 7 integers (objects)
  • 6 boxes (based on last-digit)

By the Pigeonhole Principle, some box contains at least 2 of our integers.

Check each box:

A last digit 0 B last digit 5 C last digit 1 or 9 D last digit 2 or 8 E last digit 3 or 7 F last digit 4 or 6

In every case,
two numbers in the same box have sum or difference divisible by 10.

Summary

  • Pigeonhole Principle:

    If you have too many objects for the number of boxes,
    some box must be crowded.

  • Tennis balls:

    • 29 balls, 4 players → some player has at least 8 balls.
  • “Sum or difference divisible by 10”:

    • 7 integers, 6 boxes →
      some box has 2 numbers whose sum or difference is divisible by 10.

The art is choosing what counts as a box.

Try This!

Among 40 people, show that two of them must have birthdays that are within 9 days of each other.

A Hint…

Think of the calendar as a long strip of 365 days:

 

 

What would happen if we divide the year into blocks _______________?

How many blocks is that?

The Hidden Boxes

If the year is divided into 10-day blocks, then:

  • Number of boxes =
    \[ \left\lceil \frac{365}{10} \right\rceil = 37 \]

  • Number of pigeons = 40 birthdays

 

By the Pigeonhole Principle,
some block must contain at least 2 birthdays.

Why Does This Work?

If two birthdays lie in the same 10-day block,
their dates differ by at most 9 days.

 

Therefore:

Among any 40 people, two have birthdays
within 9 days of each other.