SECTION 11 / 28

Equal birthdays become neighbouring records

1 min read
Aditya and Monika share 15 March. Sorting by the complete month-and-day key places them together.
Aditya and Monika share 15 March. Sorting by the complete month-and-day key places them together.
REAL COURSE DATA · SORT, GROUP AND VERIFY

Find shared birthdays after sorting

Follow the selected procedure. Change a field, tie rule or weekday and explain why the result changes.

Ready

CURRENT RECORD / VALUE

Ready to begin

No records have been processed. Start with Next step.

What we remember

Processed
0

Predict the next change. Keep track of which list level, field and position convention the procedure uses.

Normalize month spellings, then sort by calendar month and day number. Do not sort raw date strings alphabetically: “12 Jan” and “4 Jan” need numeric day order, and July and Jul mean the same month. Equality for this task ignores the year.

After sorting, compare neighbours using first(L) and first(rest(L)), then advance one position. A non-empty 30-card list has 29 neighbour checks. The sorting work is additional preparation, not part of those 29 checks. This dataset gives the matching neighbour pair [7,21], Aditya and Monika.

A matching-neighbour count is not always the number of ALL matching unordered pairs. A run of r equal birthdays has r−1 equal neighbour links but r(r−1)/2 distinct student pairs. Three matching students produce two neighbour links and three pairs. Count a run’s size if the question asks for all pairs.

Try it yourself

Why is sorting by month alone insufficient for immediate-neighbour equality checks?

Show explained answer

Different days in one month can interleave equal day values. Sort by both month and day.

Try it yourself

If four students share a date, how many unordered matching pairs exist?

Show explained answer

4×3/2 = 6, even though their sorted run has only three equal-neighbour links.

Try it yourself

Is the entire method only 29 operations?

Show explained answer

No. It includes key construction, sorting and then the 29 neighbour comparisons.

YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑