Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SANDBOX MY SECTION LET'S GO! Exercise 8.6.5: Bacteria Cultures to points A chemistry teacher asked her class to answer the following question: hacerta will be

image text in transcribed

image text in transcribed

SANDBOX MY SECTION LET'S GO! Exercise 8.6.5: Bacteria Cultures to points A chemistry teacher asked her class to answer the following question: hacerta will be on the doorknob by the time we come to school tomorrow? If I put 10 hacteria on the classroom doorknob tonight, hown padlave in order to answer this question, you need to know a few things: 1. Each bacterium (a single bacteria) can create 2 more bacteria every hour 2. This means that after one hour, the doorknob will have 10 -102 - 30 bacteria, since we started with 10 bacteria and each of those created 2 more 3. This means that after two hours, the doorknob will have 30 + 30 -2 = 90, since there were 30 bacteria at the beginning of hour Two, and during that hour each bacteria created 2 more bacteria 4. Continuing this pattern, the number of bacteria on the doorknob after N hours is number of bactersalaster numbrotacteria tour 2 5. However, if we wanted to know how many bacteria are alive after 12 hours, we need to know how many bacteria were alive at hour 11. To find out how many bacteria are alive at hour 11, we need to figure out how many were alive at hour 10. Do you see how we can use recursion to solve this problem? Write a recursive function that computes the number of bacteria alive after N hours The function signature is 206 plan erint hour RAW. 120 Type here to search 8.6.5: Bacteria Cultures 1 public int numBacteriaAlive(int hour) 2 - // Hint: The base case should be when hour is @ // At hour , there are 10 bacteria alive 1/ The recursive call should be to figure out how many bacteria were 1/ alive last hour SHERBOUW I/ Then you can return the number of bacteria alive this hour because // the number of bacteria alive during this hour is 1/ numberOfBacteria = lastHour + last Hour + 2 11 where lastHour is the number of bacteria alive at (hour - 1)

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

Recognize how to ensure data quality through validation.

Answered: 1 week ago

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago

Question

Have roles been defined and assigned?

Answered: 1 week ago