Tuesday 3 February 2015

Week 5: Tracing Recursion

Hello,

Last week we started learning about recursion. We began by tracing calls on recursive functions. I found this really self explanatory and fairly easy, but I am sure knowing how to trace a recursive function call is going to help me write my own resursive functions.

In last weeks lab in the last exercise we were given a problem that we were supposed to solve recursively. We were supposed to find the maximum sublist length in a list that may contain other lists. At first it I did not understand how to solve this problem and it did not make sense to me. So i was trying a lot of trial and error with code trying to get this program to work and it was not working. So what I did is just left the problem for a while and just thought about it, and after a while I came up with the idea in my head. I translated my design into code, implemented it and ran it and it worked perfectly with all the test cases I gave it.

I was pretty happy because it was the first recursive function I wrote and maybe one day I will look back to that day and remember the first problem I solved using recursion.

- Rod Mazloomi

http://upload.wikimedia.org/wikipedia/commons/thumb/4/45/Sierpinski_triangle.svg/2000px-Sierpinski_triangle.svg.png

No comments:

Post a Comment