Thursday, 2 April 2015

Recursing my thoughts on Recursion

I chose to revisit my earlier SLOGs on recursion because I feel like recursion was perhaps the most central topic in the course. So with further ado, here's how I now view recursion now as opposed to then.
I feel as though this has been covered before...
 In my first post about recursion I used what I would now consider a somewhat simplistic cake metaphor to describe my initial thoughts on the subject. I quickly discredited that metaphor by stating my real view on recursion after I spent more time thinking about it. Now, as the course is coming to an end, I've had even more experience with recursion and it's time for me to re-evaluate my thoughts on the subject.

Recursion is a difficult concept to wrap your head around but, at the same time, is an incredibly important programming tool. Originally I looked at it as running an entirely new process, inside the original process (albeit the new process is exactly the same as the original, just with different values as input). Having had more experience I now see this as a definition that is very broad in scope. One of the main data types we worked with throughout the course in a data tree. We explored how to search through the tree and find the values we want to use. However, when you think of searching trees in terms of recursion you'll find that my definition is too broad to really cover what is happening. My definition says that you are running a value check inside a value check inside a value check, etc. However, what you are really doing with recursion is traversing the data structure. And while that may be a 2 dimensional way of looking at it as opposed to processes inside of processes, that is what it ultimately boils down to. With this in mind I now understand that the benefits of recursion need to be evaluated on a case to case basis. I've stopped looking at recursion as a static concept and started to integrate it with my problem solving. I don't think in terms of "I need to call recursion on this", instead I think "this is the data structure I am presented with and I need to access it in this manner". This way I am inherently aware of both the return type and recursion format required and have a much easier time finding the solution.
I think we're done with this topic... or are we?

No comments:

Post a Comment