Ask your own question, for FREE!
Computer Science 21 Online
kekeman:

Which of the following situations would be useful for implementing a recursive function? A complex problem needs to be broken down into smaller, manageable chunks. A program is needed to be created quickly with easy to follow code. A user needs a program that can calculate the area of a room. A program that needs to conserve memory usage while running.

SmokeyBrown:

A recursive function is, by definition, a function that calls itself. Usually, the purpose of this is to break the problem down into smaller and smaller pieces with each "call" until the final "baseline" call, where the problem is easy enough to solve; then, the function goes back through each of the previous calls, adding the solved pieces back together to return the final answer. A simple example to illustrate the recursive logic: Imagine you are standing in a line with an unknown number of people, and you do not know your place in the line. You want to know how many people are in front of you. So, you ask the person in front of you what number they are, reasoning that you can take their number and add 1 to get your number. However, the person in front of you also does not know their number. This is where the recursive solution comes in. The person in front of you can ask the person in front of them, who can ask the person in front of them, recursively, all the way until the person who is standing in front of the line. Of course, the person at the very front is the "baseline" number one. Once person number one is reached, they can tell the person behind them "I am number one," which will let that person know they are number 2, which will let the person behind them know they are number 3.... and so on, until they get back to you. That's recursive problem solving in a nutshell. In this case, the big problem of "what number am I" was broken down into many smaller problems of "what is the number of the person in front of me"

kekeman:

Ok so with saying that what do you think it is?

link1234:

i think its the first one

SmokeyBrown:

@kekeman wrote:
Ok so with saying that what do you think it is?
Apologies for the late response. I was getting at the usual use of a recursive function would be to break a large problem into smaller more manageable pieces. So, I would agree with link1234, I think the first option is the best, for the reasons outlined above.

kekeman:

Np and thank you for the help!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!