Tuesday, 3 December 2013

Mid-Term 2 Results , Property, and MapReduce (Week of Nov. 18th)

The TA’s for this course marked really quickly! It only had been a week and Professor Heap had already returned the Mid-Term back to us. I did generally well on this Mid-Term, and I believed the results truly reflects my knowledge on recursive tree structure (including binary tree as well as binary search tree). For question 1, it asked us to return a tuple containing the number of interior nodes and the number of leaves in the tree. Since I was not really familiar with tuple, I decided to write two helper functions within the count_node function: one function would count the number of interior node while the other would count the number of leaves. count_node would then call upon the two help methods and return the intended result as a tuple. For question 2, it asked us to return the number of nodes with value that was even. This question was pretty straightforward; the code for this function was very similar to the function that counts the number of nodes in a whole tree, just with a slight modification. As for question 3, it asked us to build a linked list of the path from root to minimum element. It was really similar to the question we did in lab08, where we had to use linked list structure to represent inorder traversal of a recursive tree. However, I for some reason checked for right child of the BST when I was writing my answer. Consequently, I got 2 marks off question 3 (and the whole Mid-term). Nonetheless, I am still very satisfied with the result!
This week we learned about the Property function as well as MapReduce, in which both functions were very new to me. One of the functions of Property is that it can restrict the attributes of an object. Property takes in four arguments: function that get the attribute, function that set the attribute, function that delete the attribute, and a docstring. They are all None by default. Professor Heap only went through the first two function arguments (get and set). At first, I was really confused in class, I have no idea when the program would invoke the get or set function. However, after reading the background material posted on the CSC148 website, I was more comfortable with Property as I got to see different examples on the internet. Similar to Property, MapReduce is very new to me, especially the Reduce part. I did not know how reduce work at first, so I decided to ask my friend to explain it to me. Now I understand that reduce combines elements of iterable into a single reduced value. I believe by reading background material and consulting friends in computer science, I have a better grasp on how to use Property and MapReduce.

No comments:

Post a Comment