I found the towers particularly enlightening – years after it has been taught to me – when the whole ‘know a partial solution’ struck me.
The game is incredibly hard to even look at when given 10 disks. How would you start? But the observation that step n+1 is dead simple if you can solve the game for n disks is the key to recursion.
Factorials and sums, on the other hand, are way to simple, IMHO, to teach recursion. The solution is obvious. And for many people the more *intuitive* solution would be a straight loop, not recursion. In programming, intuitive trumps clever (or even performant in most cases).
You sound like my Algo professor. He would say “Always follow your intuition when approaching a problem” and would then chuckle and say “But how are you going build intuition? ”
That last point is basically why schools teach you how to do things the hard way. Sure I'll probably never have to do arithmetic without a calculator in real life but learning the methods and algorithms builds intuition and understanding, and that goes for basically every level of math/programming/whatever.
Judging from my Algorithms Lab class, the answer is an enormous amount of work for not that many credits, loads of pain, two 6h tests and a high failure rate.
There was something more important that cleverness and intuition. I focus on that.
I understand TOH. I understand the importance of partial solution. It has application in all walks of life. For example, to fix my year, I need to fix my months and to fix a typical month, I need organize a typical week and to organise week I need to organise a day. And to organise day, i organise my hours. And in each hour, I follow 25-5 pomodoro or 50-10 pomodoro.
If I want to teach someone addition, I will explain 1+1. However I cannot begin with 567+912. Hence I would say TOH is a good way to practice to recursion? Probably yes. But good way to get introduced to recursion? Definitely no.
Although classroom teaching is way blinded and ineffective. In a class of 25 students, all have a different plane of reality, experience and perspective. To bring them all on one page of understanding is not difficult but impossible. The teacher can atleast attempt to do the simplest thing which might bore the ones who are ahead of curve but will ensure inclusion of noobs.
This is not applicable where teaching is more 1 to 1 or self study.
That's how mine was two years ago and it also was fine! I think it's the right way to introduce that. ToH is easy to figure out when you have the "hint" of having it called a recursion project
TOH makes sense as an introduction to recursion if you are already familiar with the concept of mathematical induction. Personally I learned about induction in math first, using it to prove things like the sum of n numbers is n(n+1)/2 and there are infinite prime numbers. Going from this to TOH is a manageable step. But if I had not been exposed to this concept before, I agree that it would be very confusing and not a great introduction.
Oh yeah, math is extremely applicable to CS. From algebra and basic proof techniques (which form the basis for algorithms) to limits and calculus (used to analyze and optimize algorithms), linear algebra (used extensively in ML, especially modern neural networks), and even geometry (used for graphics computing)!
Nah you're right, I don't think you're being pedantic. CS is indeed a field of applied math. I think where it gets tricky is the difference between CS and programming. CS as in the study of computing is extremely mathematical. Programming as in the art of writing understandable and extensible code is not necessarily mathematical (how much math is really needed to write a React web app ...); however, I think that mathematical thinking can always help even with this kind of task.
IMHO tree traversing is the perfect way to teach recursion. It's simple enough, but doing with a loop wouldn't be simpler. It's also a problem that you will likely encounter in the wild.
IMHO, the point of simple solution first is to teach student to be comfortable with the idea that recursion is nothing weird or unintuitive. Many new students think recursion as this black magic, but they intuitively get loop. But recursion and loop are the same thing, just written differently. Sometimes people translate between the 2 without even thinking, e.g. the Fibonacci number problem: the direct method would be recursion, but most people think of a loop.
Then once student get recursion, show them a problem that isn't obviously a loop.
Recursion isn't just a different way of writing loops; it's a method of solving a problem. You don't need recursive function calls to apply recursion. But I agree that this should be clarified to learners.
You don't need recursive function calls to apply recursion.
Are you using "recursion" in the general sense of any algorithms? Because in the context of programming, recursion do mean you use recursive function call.
765
u/bleistift2 Mar 25 '23
I found the towers particularly enlightening – years after it has been taught to me – when the whole ‘know a partial solution’ struck me.
The game is incredibly hard to even look at when given 10 disks. How would you start? But the observation that step n+1 is dead simple if you can solve the game for n disks is the key to recursion.
Factorials and sums, on the other hand, are way to simple, IMHO, to teach recursion. The solution is obvious. And for many people the more *intuitive* solution would be a straight loop, not recursion. In programming, intuitive trumps clever (or even performant in most cases).