On May 3, 2:50 am, harrismh777 <[email protected]> wrote:
> The thing about this problem that puzzles me, is why we might consider
> recursion for a possible solution in the first place....
This can be answered directly but a bit lengthily.
Instead let me ask a seemingly unrelated (but actually much the same)
question.
Here are two power functions:
def powI(x,n):
result = 1
for i in range(0,n):
result = result * x
return result
def powR(x,n): return 1 if (n==0) else (x * powR(x, n-1))
What are their space/time complexities?
Which do you prefer?
--
http://mail.python.org/mailman/listinfo/python-list