Sunday, March 15, 2015

Week8: impressions of week 7



Week 7 is the first week after the reading week. We continued on the topics like binary trees and binary search trees (bst). Binary tree is a kind of tree which has two named children left and right, and binary search tree is a binary tree with its left child smaller than its valve and right child larger than its value. When it comes to the concept of binary tree and bst, it’s not very challenging as we have learned tree before. However, we have to write some recursive methods again using binary tree. For example, __contains__ requires us to find whether an exact value is in the tree. To solve this problem, we can depend on its own attribute such as a binary tree has only two children. In further steps, __contains__ method in bst can be more effective because we are supposed to use the attribute that left child is smaller than its value while right child is larger.

This week we learned about some new stuff—linked lists. It has two concepts, LLNode referring to a linked list and LinkedList, a wrapper class for list. At first, I got into trouble about LinkedList. I had the wrong concept that self.front just refer to the first node of LinkedList. So I can’t figure out the right methods due to this wrong concept. After reviewing the slides and looking at the code prof writes, I come to know what mistake I have made and try to redo the problem again.



This week’s lab is about binary tree. I was unable to write recursive functions at first because I didn’t know how to think the problem recursively and how to choose the base case. So I turned to TA for help. In conclusion, the first step is choosing an easiest case that doesn’t need recursion as the base case. Then call the function in more complex cases.


No comments:

Post a Comment