How not to teach recursion (2021)
11–20 of 121 posts
Re: How not to teach recursion (2021)
#12I'm still looking to understand the difference between recursive definitions and inductive ones...
Iteration is just recursion over a list/array/generator.
def sum(arr):
total = 0
for x in arr:
total += x
return total
and def sum(arr):
if len(arr) == 0:
return 0
return arr[0] + sum(arr[1:])
both operate over an array but I'd call one of them recursive and the other iterative.Re: How not to teach recursion (2021)
#13While I agree with the overall argument, reading this was a bit frustrating. The article made all kinds of interesting points and observations, but didn't really explain any of them. For example, I'd love to know what the difference between recursion and cyclicity is.
Re: How not to teach recursion (2021)
#14Once they've "earned" the usage of the built in methods, they are tasked with rewriting them again, but this time without using any kind of looping. I give them a bit of time to think about how they may do this. Very few students get it but the plan is to live code it myself as an introduction to recursion. The task is still the same: to rewrite the map method. So the context for their intro to recursion is something they've become quite familiar with. It seems to have worked well.
Re: How not to teach recursion (2021)
#15Re: How not to teach recursion (2021)
#16I'm still looking to understand the difference between recursive definitions and inductive ones...
A recursive definition is: "natural numbers are 0 or a natural number + 1". An (abridged) inductive proof that uses the recursive nature of natural numbers: "the sum of all naturals up to n is n(n+1)/2: 0*(0+1)/2 = 0, and (n+1) + n(n+1)/2 = (2(n+1) + n(n+1))/2 = (2n + 2 + n^2 + n)/2 = (n^2 + 3n + 2)/2 = (n+1)(n+2)/2 = (n+1)((n+1)+1)/2"
Re: How not to teach recursion (2021)
#17The tl;dr here is “just use HtDP” (which I agree with).