Looking back on some older posts from week 3 or so I realize how much we've covered in this class so far. I forgot we began by thinking about inheritance and composition and I find it interesting how I can still recall what those terms mean and how they've become second-nature to me now. In week 4 I couldn't imagine how Linked Lists could be implemented without themselves just being composed of python lists. At that point I really didn't see how versatile class-building could be. I thought python had certain data types already and all we could do was slightly alter how they operate. While it's true at some level all we are doing is altering these basic python data types whenever we create a class we are also altering and combining and manipulating them in such incredible ways they really can be almost unrecognizable after it's all done. I couldn't see to get past the idea that anything we wanted to behave as a list must inherit a list or be composed of a list. This class has really awoken me to how different ADTs and classes can be developed and the power behind them.
Wednesday, 30 March 2016
Week 11
I'm looking back on my "real" week 6 entry about recursion and am noticing I've learned a few things since then. In week 6 I figured the only way to implement recursion was to have if statements in your code that could eventually get to a point where the recursive calls end. The thing is, I'm not sure if this is the only way to do it, though I still think it is, but in week 6 I was envisioning these if statements and all of the information they received as being completely contained in the body of the function. But while writing code for this second assignment, mainly for the depth first search, I made use of variables in a different way then I had thought of before - global variables. I wrote code that updated these global variables and, most importantly, one of them was directly used to prevent a branch of code containing a recursive call from being accessed. And in one of the last few lectures we also saw that you could add an argument to the function that gets updated with each new recursive call, and this argument can take on a value that effects an if statement appropriately. So, while I still think if statements probably are the only way to do it (I suspect the more advanced and sneaky code that is recursive must still contain some idea of an if statement or a condition), I'm seeing that the ways in which these if statements work is not always dependent on code that seems strictly contained in the function body… global variables and "outside" things can impact it too.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment