This week in class we learned about recursion. I think recursion is kind of hard, because to understand a recursive function, you need to think as if you were the computer and calculate what each step does. This process is called tracing. Tracing code is necessary to understand it, as well as to implement new functions involving recursion. It's kind of painful and energy consuming to do it but I suppose I'll get better I get more familiar with it. I just need to exercise more, just as in anything else.
Other than being hard I think recursion is a cool concept. It is a nice way to overcome some programming challenges. It's basically telling the computer to do something, until something we specified earlier changes, it is kind of like while or for loops we already use but it's very different. Calling a function from inside its own body seemed kind of odd at first but it is actually a brilliant way to do things. Well, I can't guess of any examples which can only be done using recursion but I am certain that it will become handy in many tasks awaiting us. Have a good week.
No comments:
Post a Comment