SECTION 02 / 17

Find students with the same birthday

2 min read
On this page 2 headings

For this task, “same birthday” means the same day number AND the same month. The year does not matter. Two different students born on 15 March match; 15 March and 15 April do not.

The supplied cards contain one matching birthday pair: Aditya and Monika, both born on 15 March.
The supplied cards contain one matching birthday pair: Aditya and Monika, both born on 15 March.
REAL COURSE DATA · THINK BEFORE EACH STEP

Find matching birthdays: every pair

Trace the records, compare the methods and watch what changes. Back and Reset let you try again.

Ready

CURRENT RECORD X

Ready to begin

Choose Next step to follow the actual course records.

What we remember

Processed
0

Start with Next step. Predict what changes before reading the explanation.

Ask the right question before choosing when to stop

“Is there any matching pair?” needs a true/false answer. Stop once a real pair is found. “How many pairs match?” needs the whole scan. Finding the first pair is not a general way to count all the pairs. Changing the card order can change the first pair found and the work before early stopping, but not the complete set of matching pairs.

A student must never be matched with their own card. Remove X from the search or use a separate identity such as CardNo to exclude it. Names can repeat in a larger dataset, so an identifier is safer than a name for deciding whether two records represent the same student.

Why is this called the birthday paradox?

In a simplified model with 365 equally likely birthdays and independent people, 23 people already give a little over a 50% chance of at least one shared birthday. It is a probability, not a guarantee. The chance that somebody shares YOUR birthday is a different question. You do not need the probability formula to trace the search.

Try it yourself

Three different students share one birthday. How many matching unordered pairs are there?

Show explained answer

Three: A–B, A–C and B–C. There is one shared date, three students on that date, and three pairs. These are different counts.

Try it yourself

May 15 and March 15: match or no match?

Show explained answer

No match. Both day AND month must agree.

Try it yourself

Can a class of 30 students have no shared birthday?

Show explained answer

Yes. A likely event is not a certain event. The search must be able to return false after checking all eligible pairs.

YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑