Saturday, October 26, 2013

Week Seven

October 26, 2013.

With the midterms over, the amount of work has calmed down in a sense. Though the complexity of the homework and exercises only seemed to grow more difficult. This week as we learned of the function helper call in class methods, it helped understand how different parts of the class parameters are called in different ways. If it is anything I had gained a clearer understanding of this week was that class parameters, when already defined, can take additional parameters if they contained recursive properties. For example:

__init__(self, left, right):
to
[inside a function method call]
self.left.node
self.right.right.left.node


This method also gave me a clear understanding of writing certain helper code to certain method calls. In the case of the exercise 5, I found it helpful to define a helper inside set_depth function which recursively accounted for counting all the nodes within a binary tree. That goes without saying that, for this exercise, I had the trouble of figuring out how to recursively assign variable statements if the variables were defined with different names. I realized the idea of this part of the exercise. Here is an example of what I mean.

if X:
return 1 + sum(self.item.set_depth(4))
vs.
if X:
return 1 + sum(self.item.left.left.set_depth(3)...)

If I were to say the most challenging of the exercises so far, it would be this one.

Another key idea I have came to learn this week was tuple unpacking. Understanding that tuple can be seperated by "," it gave me a clearer understanding (and a better method) of how assignment statements would work in a much simpler format.

As the coding of concept gets more complex, I hope to gain a better knowledge of how to properly translate my ideas of solving an algorithm to code.

Cheers!


No comments:

Post a Comment