Homework 2

Short Description:

Write a program which will find the average number of people in a group needed to have two with a common birthday in MIPS assembly language.

This assignment is worth 30 points.

Goals

When you finish this homework, you should:

Formal Description

The Birthday Problem asks how many people, on average, need to be present in a room for two to share a common birthday. The surprising answer is 23. You are to write a program, in MIPS assembly language, which will simulate this.

A single trial for this simulation consists of adding people to a group until a duplicate birthday occurs. To do this, generate a random number between 0 and 364 (we will ignore leap year) to represent the day of the year on which a person was born, then check to see if this date matches any of the people already in the group.

Your program should conduct 2n trials, totaling the number of days for each trial. Once finished, the approximate average number of people can be calculated by shifting the total to the right by n.

Discussion

Make sure your program is well structured and well documented.

You do not need to use floating point computations for this program.

You should prompt the user for the value of n

You should prompt the user for a verbosity level:
Verbosity Level What is printed
0 final answer
The average number of people required for a duplicate birthday in 1024 trials is 23
1 One line per trial stating the person number and day number when the duplicate birthday occurred.
Duplicate birthday at person 57 on day 126.
2 One line per person per trial stating person number and birthday
Person 1 has a birthday on day 102

You do not need to worry about efficiency of data storage. This problem could be done with bit operations, but that is not required, nor necessarily desired.

I would begin by writing a program in a high level language and translating this to assembly language.

Required Files

Your assembly file.

Submission

Email your assembly file to danbennett360@gmail.com by March 14 18 at class time.