SECTION 11 / 31

Use day and month as a birthday key

1 min read
Aditya (7) and Monika (21) share 15 March. The 30 original students have 29 different day-and-month birthdays.
Aditya (7) and Monika (21) share 15 March. The 30 original students have 29 different day-and-month birthdays.
REAL COURSE DATA · KEYS, COUNTS AND CONNECTIONS

Four birthday dictionary representations

Follow the dictionary as its keys and values change. Predict each lookup or update before revealing the next step.

Ready

CURRENT RECORD / VALUE

Ready to begin

No records have been processed. Start with Next step.

What we remember

Processed
0

Predict the next key, whether it already exists, and the value that will be stored.

Earlier weeks used all pairs, month bins and sorting. A dictionary provides another route: read each student once, compute a day-and-month key, and go straight to that birthday’s entry. A key such as “15 Mar” combines BOTH day and month. The year is ignored for this shared-birthday task.

Normalize known equivalent spellings before making keys. In these cards, Jul and July mean the same month. Different birthdays such as 15 Mar and 15 May must remain separate. Do not compare only month, and do not compare only day number.

After all 30 records, one repeated key is 15 Mar, associated with IDs [7,21]. The other 28 observed keys each have one student. Therefore there are 29 distinct birthday keys. Finding a shared birthday in this class is an observation, not a guarantee that every class of that size has one.

Try it yourself

Is the key just “March”?

Show explained answer

No. That would group everyone born in March, including different days.

Try it yourself

Should birth year be included for this task?

Show explained answer

No. The task asks for a shared day and month.

Try it yourself

Do 29 dictionary keys mean only 29 students were processed?

Show explained answer

No. Two students share one birthday key, so 30 students produce 29 distinct keys.

YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑