Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 2: Count Bacteria Population A certain species of bacterium reproduces according to the following rules: - A bacterium born in day n does not
Problem 2: Count Bacteria Population A certain species of bacterium reproduces according to the following rules: - A bacterium born in day n does not give birth to new bacteria in day n and day n+1. - A bacterium born on day n gives birth to 1 bacterium on day n+2. - A bacterium born in day n gives birth to 2 bacteria in day n+k, for each k>2, i.e., a bacterium born in day n gives birth to 2 bacteria from the (n+3) rd day onwards. - A bacterium does not die. Let Pn denote the population of bacteria on day n. It is provided that P0=0 and P1=1. In this problem, n is given as input, you have to output Pn. For example, P2=1 because the bacteria born on day 1 does not replicate on day 2 . On day 3 , a bacterium is born of the 1 st bacteria. So, P3=2. On day 4,2 bacteria are born of the 1 st bacteria and none of the 2 nd. So, P4=4. Restrictions: Arrays cannot be used for this task. Use a recursive method with the following prototype
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started