Wednesday, February 11, 2015
So since my last post, we have written our first term test in this class and are approaching the halfway mark in the semester. I was unable to make it to lecture today so I did not get to see the results of my term test (hopefully they were good *crosses fingers*). We are also supposed to do a review exercise that is attached to the test which is worth 1% of our final grade. I have not seen this review exercise thing yet, but it seems like a great way to review the test to make sure we, as students, can understand our mistakes moving forward. I would love to see my other courses do this as well, plus we get free marks! :-)
In class this week, we learned about trees which is a pretty cool topic. I have been told about them before by my friends who have taken the course before, so I had a very small idea about them. With trees, we can use recursion to go through the tree to find the information or pieces of information that we need. Recursion is still a fairly new topic to myself so I need to make sure I can understand it well before begin messing around with trees. I made the same mistake on both the quiz for lab 3 and the term test when tracing recursive functions. For example:
def m(L):
if isinstance(L, list):
return 1 + sum([m(L) for x in L])
else:
return 1
Trace ca([15, 3, [5, 19], 32]).
*This example was taken from quiz#3, Q3 in T0501 (Fri 11-1)*
When tracing this function, I know that I will get 1 for the first 2 items since they are not lists. Then for the next item, since it is a list, it will be the sum of 2 one's, PLUS another 1 since that is what the code says. I keep forgetting to add this extra one when tracing, or whatever that extra addition should be (ie. on the term test, it was len(L)). So my answer is one less than what is should be.
Hopefully I stop making this mistake, because it is frustrating and hopefully by typing it out like I just did I will not do it again. Hehe :)
No comments:
Post a Comment