Because of the midterm we didn't exactly cover much during lecture this week. The midterm went fine, although the marks aren't out yet to determine how we did. Since the SLOG requirement for this week is about tracing recursions, I might as well talk about that.
...I don't really know what to talk about tracing recursions. It's pretty helpful for one to see what exactly the function does and how recursion works, but I suppose that's it. Tracing is rather boring once one understands what's going on, and gets frustrating quickly. So I'll write about recursion in general instead.
Judging by what we've seen so far, recusion is indeed useful as for reducing code complexity for tasks, since it is much simpler than layers of dreaded if-then statements (which might not even work), and for general problems which may or may not be doable (efficiently) with what we've learned in CSC108. Quick sort is the obvious example for the latter motive, with an average performance of O(nlogn), it works much faster than the sorting algorithms we learned before which all has average performance O(n^2).
It seems that we're going to be working on recursion for a while, as both the examples done in lecture--quick sort and the example on checking imbalanced parentheses--are both applications of recursion, and as the SLOG requirements for later weeks are often on recursion. Looks like I'll have to revisit this topic a few times in the future when we learn more about it.
No comments:
Post a Comment