[Solved] Python recursion facts


1) A recursive solution has a few benefits. Generally it is more readable, and smaller in terms of lines of code. When it doesn’t work, it’s almost always harder to debug. It’s usually preferable when it runs faster than a non-recursive solution (see merge sort).

2) By definition.

3) True — the point of recursion is to reduce every problem to a base case which has a trivial solution.

4) Also true. See the implementation below:

def pow3(input):
   if input//3 is not input/3:
       return False
   elif input is 1:
       return True
   else:
       return pow3(input/3)

5) Based on the wording of the question, “one or more recursive steps”, certainly true. Every recursive function must have a recursive step, and therefore every recursive function must have one or more recursive steps.

Feel free to ask any other questions below.

4

solved Python recursion facts