Google interview questions: Are there more boys or girls?

Hello everyone, I'm Xiaohui, a programmer. I haven't published comics on the public account for a long time.

Today's cartoon is adapted from a famous interview question from Google. This problem is a math problem, not very programming related, but very interesting and interesting. Xiao Hui is sharing with you today.

9eaa24a945b7bf20f9bd405854cf3cdb.png

c1434f40883e16c25a1065b4a1ab02dd.png

----- the next day -----

4ec9d2ae57f195cb20b0301babf2da0c.png

85dd10869d89b77c68efb47788bb994a.png

63b31f86798c2f50511acb4036449501.png

1b69df7b0a616f3c3d5cfd9c29a80032.png

90a71becfd0a489681b466854fd12a11.png

94a290bf01d055f1aa8345f9255e35cc.png42fb6e381ffe18259ace1b259c73ab1c.png5bafff89247ad44a39ce117fb07c6423.png

afcc7960ece5e44c7d2b50e3d8d12265.png

————————————

0c98f965af716747d5fb3fe3751cc3f3.png

9d5f58cc41ad5599a3fa505a2fb9e4b3.png

73c49f6bbaa777b9c903adfc1c30090a.png

Xiao Hui told Rhubarb about the interview questions she encountered. . . . . . .

0682806afd8eab2b17e6e4bcdc0e7e5d.png

a34eae457a5e6d9ec47ce97314d3bd96.png

b33fa58b574bb306d736b3d1cb5e8065.png

Suppose there are n young couples in a region preparing to have children:

4f7a0e914e1f40b1a230f664fceb65d8.png

If the odds of having a boy and a girl are 50% each, then among the first babies, n/2 will be boys and n/2 will be girls:

7658921a8e57c258a29d64f28ada4916.png

According to local customs, families that give birth to boys do not have children, and families that give birth to girls continue to have children. So n/2 families will continue to have children, and in the second batch of newborns, n/4 boys and n/4 girls are added:

486c2e9a097cbcf7b15ec8e29d8eb7b8.png

By analogy, the remaining n/4 families will continue to give birth. Among the third batch of newborns, n/8 boys and n/8 girls are added:

a0eb88e937160d6406eb428e1166fc09.png

If it continues, the remaining n/8 families will continue to give birth. Among the fourth batch of newborns, there will be n/16 boys and n/16 girls...

7ed00512850932b74cbc0293345bc477.png

c74bb7ae7b0a7f4b209661710d19f319.png

5b9242d0cbe323e17064600631bb1be1.png

30080349683889b5ff840fbb5fcd5823.png

6a361199bd92a0d83cf18569a2a45b22.png

db616c94ab20a23f51b7c7e64499ca15.png

e963a382ad3ec944062585aeeaec27d1.png

9459e643b94d38cca97dcda759f304d5.png

e99043b5a46ed0d67bae05199f9e0699.png

4642a69e5fa52f6b0db582b66c764115.png

6ba9fb7be79242f180f88764cc497388.png

4a7948c4f5a908c928c5233591ce9e78.png

331d968ed03ba9b2535ba298e0aa9346.png

0a601417a433ae5282be38d5da9379cd.png

71b80c8721e58bd313a6041a0309b3dd.png

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326640193&siteId=291194637