Give an explanation for the following statement: \"Recursion is more appropriate
ID: 3839449 • Letter: G
Question
Give an explanation for the following statement: "Recursion is more appropriately described as a programming technique rather than as a control construct." In what way(s) is a recursive method similar to a While loop? A programmer who wishes to write a recursive method will use a statement that evaluates a condition that determines whether the method will call itself again. In Alice, what is the control construct that is used for the decision-making statement? One "flavor" of recursion is generative, where actions build up and up until some conditional goal is met. Describe the second "flavor" of recursion. At least one of the cases in an If statement must not include a recursive call. Why?Explanation / Answer
1.In most programming languages, recursion is a specific combination of two control structures:
function call -- to solve a reduced case
if/else -- to test for and avoid
Those control structures are widely used for things other than recursion, so (in such languages, anyway) recursion is an arrangement of control structures to accomplish a type of task. That is, it's a "programming technique".
Of course, there is always the possibility that some language might have a control structure to exactly match recursion, with a syntax specific to describing base and recursive cases. In such a language, recursion would be a control structure.
In most machine languages, most everything beyond goto, conditional goto, call and return is a "programming technique".
2. Anything done with recursion can be done with while loops. The general idea is the same - i.e., you have something done, and then a test at some point to decide whether to do that thing again, or stop. However, recursion can be conceptually simpler to code rather than looping.
Tail recursion has the same results as a while loop and often the code could work just as well with a while loop.
a while loop is equivalent to a tail recursive function and recursive functions need not be tail recursive.
4. Structura recursion is the another flavor of recursion.
Structural recursion performs much of the work on the way back up through the. layers of recursion. The key difference between structural and generative recursion is where a recursive procedure gets the data that it works on and how it processes that data. Specifically, for structural recursion, a recursive call is made on a subset of the original input data. Whereas for generative recursion, a recursive call is made on data that was constructed/calculated from the original input data.
5. The general (recursive) case is the more complicated case of the problem that isn't easy to answer directly, but can be expressed elegantly with recursion. The general case is the place where the recursive calls are made . It is written so that with repeated calls it reduces to the base case (or brings you closer to the base case). Must eventually be reduced to a base case; if not --> infinite recursion. Must have at least one general case --> if not, no recursion!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.