Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Jul 2017 |
Last Sign in: | 211 Weeks Ago, 2 Days Ago |
Questions Answered: | 15833 |
Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
a} 1iWrite a script for the birthday problem and run it. Make sure you get the correct probabilities,
which you can “Google” to find. b) Modify the code so that it finds when there are at least two matches, i.e., either at least three
people have the same birthday, or there are at least two distinct matches. c) Modify the code so that it finds when at least three people have the same birthday. Check this
forn=3fl,40, ...,1flll Hint (this part only): Suppose 21] people have the following, already sorted, birthdays
13 1? 25 50 51 99 99 1'03 2G1 229 22E;l 229 23? 255 289 289 293 30? 341 When we diff this vector and then replace all nonzero values by U and all zero values by 1,
we obtain 000001000110UU10000 Notice the two consecutive 1‘s which correspond to the three consecutive #22Q’s. All we need do is determine if any successive ones occur. Let (1 be the above vector of l[I’s and 1’s.
If we add successive pairs of elements by 2-:- d(1:end—1) + d(2:end) we obtain what is needed.
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly