Question: NOTE: You can read about his problem in WIKIPEDIA. Here is a link: https://en.wikipedia.org/wiki/Birthday_problem /** * Perform an experiment simulating the birthday problem. * Pick

NOTE: You can read about his problem in WIKIPEDIA. Here is a link: https://en.wikipedia.org/wiki/Birthday_problem

/**

* Perform an experiment simulating the birthday problem.

* Pick random birthdays for the given number of people.

* Return the number of pairs of people that share the

* same birthday.

* @param numPeople The number of people in the experiment.

* This value must be > 0

* @param numDaysInYear The number of days in the year for this experiment.

* This value must be > 0

* @return The number of pairs of people that share a birthday

* after running the simulation.

*/

public static int sharedBirthdays(int numPeople, int numDaysInYear) {

// check preconditions

if (numPeople <= 0 || numDaysInYear <= 0)

throw new IllegalArgumentException("Violation of precondition: " +

"sharedBirthdays. both parameters must be greater than 0. " +

"numPeople: " + numPeople +

", numDaysInYear: " + numDaysInYear);

//Data Structures STUDENTS: ADD YOUR CODE HERE!

return -1; //must change

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!