Sorry for the 2 week delay in posting a new entry, but last week was reading week so I took time out from all the stress university work brings and just chilled. Anyway, now that reading week has ended, let's get back to CS related topics shall we?
This week I want to talk about recursion. Recursion has been a very new concept to me, having never worked with it in my life. Now that I've spent quite a bit of time understanding recursion, I'm hoping I can summarize it to the best of my ability. Based on my understanding, recursion always requires a base case. Sometimes there can be more than one base case. A base case is simply a scenario that doesn't require me to call a function on itself (which is essentially what recursion is). Sometimes this base case(s) can be quite straightforward, while at other times it isn't. This requires the use of an if statement. However, there are times when the condition for the base case isn't met. This is where recursion comes in. Based on my understanding of recursion, when the base case isn't met, the function calls on itself, after which it checks again whether the base case condition is met or not. The function will keep calling on itself until the base case is met, after which it will be fully evaluated. This is how my understanding of recursion. As you can probably infer, I'm still not that confident with recursion, and seeing as we will still be focusing on recursion quite a bit in the coming weeks, I think I better get back to ingraining it in my mind.
This week I want to talk about recursion. Recursion has been a very new concept to me, having never worked with it in my life. Now that I've spent quite a bit of time understanding recursion, I'm hoping I can summarize it to the best of my ability. Based on my understanding, recursion always requires a base case. Sometimes there can be more than one base case. A base case is simply a scenario that doesn't require me to call a function on itself (which is essentially what recursion is). Sometimes this base case(s) can be quite straightforward, while at other times it isn't. This requires the use of an if statement. However, there are times when the condition for the base case isn't met. This is where recursion comes in. Based on my understanding of recursion, when the base case isn't met, the function calls on itself, after which it checks again whether the base case condition is met or not. The function will keep calling on itself until the base case is met, after which it will be fully evaluated. This is how my understanding of recursion. As you can probably infer, I'm still not that confident with recursion, and seeing as we will still be focusing on recursion quite a bit in the coming weeks, I think I better get back to ingraining it in my mind.
No comments:
Post a Comment