Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ and use only library and do not use bool type. Problem You will run a simulation to demonstrate the birthday paradox for group sizes

C++ and use only library and do not use bool type. image text in transcribed
Problem You will run a simulation to demonstrate the birthday paradox for group sizes ranging from 2 50. Requirements Name your file exam1.cpp .Place the following declaration in the global space: const int MAX_CAP 50; . Use the following function prototype: double runsimulation (int size); The program takes no input from the user For each group size, run a simulation and use the results to calculate the odds of two people sharing the same birthday For example, the first group has a size of 2 Generate two random birthdays using the ordinal day of the year o o - Jan. 1 is day 1, Jan. 2 is day 2, See if there is a match Generate new birthdays and see if there is a match 4999 more times (for a tota of 5000 runs) Divide the total number of matches found across the 5000 runs by the number of runs; this is the probability that two people in that group will share the same birthday in a group of 2 Feb. 1 is day 32, .Dec. 31 is day 365 o o o o Repeat for group size of 3, 4, 550 .Print a message to the screen showing the odds of a same birthday for each group A [truncated] sample run of your program shall look like this: For 2 people, odds of two birthdays is ~0.3%. For 3 people, odds of two birthdays is ~0.68% For 4 people, odds of two birthdays is ~1.64%. For 22 people, odds of two birthdays is ~47.98%. For 23 people, odds of two birthdays is ~51.5%. For 48 people, odds of two birthdays is ~95.82%

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

Genetic Databases

Authors: Martin J. Bishop

1st Edition

0121016250, 978-0121016258

More Books

Students also viewed these Databases questions