Question: C++ The assignment this week is to develop a recursive algorithm to determine how many generations it will take before a population reaches a certain

C++ The assignment this week is to develop a recursive algorithm to determine how many generations it will take before a population reaches a certain size. I have provided you with a function uint updatePopulation(uint n) that takes a population number and returns the next step in that population growth. The algorithm I'm using for this problem is very straight forward current population - average deaths + average births. In reality the update population function would grow to become much more complicated, could have any number of contributing factors involving population size, existing land etc, etc BUT notice the underlying algorithm for calculating population over multiple generations would remain the same if written correctly to depend on the updatePopulation function. You assignment is to fill in the function howManyGenerations(uint start, uint final) that RECURSIVELY determines how many generations it will take to reach the final value given the start value.

#include #include #include using namespace std; typedef unsigned int uint; uint updatePopulation(uint currentPopulation) { uint numBirths = .0185*(currentPopulation); uint numDeaths = .0008*(currentPopulation); return currentPopulation + numBirths - numDeaths; } uint howManyGenerations(uint startAmount, uint finalAmount) { /// /// insert your code here /// return 0; //update this return value as appropriate } int main() { uint finalAmount = 1000000; uint startAmount = 100; if (howManyGenerations(startAmount, finalAmount) == 537) { cout<<"PASSED start=100, final=1000000"<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!