Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ex 2. Birthday Problem (30 points) What is the probability that students in your OOP class have the same birthday (same day and month)? The

image text in transcribed
Ex 2. Birthday Problem (30 points) What is the probability that students in your OOP class have the same birthday (same day and month)? The probability might be higher than what you think! This is a well-known paradox in probability theory. You will write in this exercise a program to estimate how many random people on average you need to meet before meeting someone with the same birthday as someone you met before. Assume that birthdays are represented as numbers from to 365. For example: January 1 is January 2 is 1, January 3 is 2. December 31 is 365 A. Implement function int mimic() that keeps generating random birthdays (numbers between 0 and 365 inclusive) and stops when a birthday is generated for a second time. The function returns the number of birthdays that were generated Hint: You can use a boolean array to keep track of which birthdays have not been seen before B. Write a program that calls mimic() 1908 times and then prints the average of the results retumed by the function. ! Info. The probability of two students in a class of size 30 to have the same birthday is around 70%. If the class size is 50, the probability is around 97%

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

Give three other names for minimum attractive rate of return.

Answered: 1 week ago