Impression about week 9(EXAM)
Although week if the exam2 week(exam was extremely hard), in the morning lecture, we still learnt something about Binary Tree node:
The above is the general form of the BTNode. Unlike what we learnt a few weeks before(LLNode), in the BTNode, there are left_node and right_node. The left_node is less than the parent.value, and the right_node is larger than the parent.value.
The following is the basic code of BTNode:
class BTNode: '''Binary Tree node.''' def __init__(self, data, left=None, right=None): ''' (BTNode, object, BTNode, BTNode) -> NoneType Create BTNode (self) with data and children left and right. ''' self.data, self.left, self.right = data, left, right
There are also some things I learnt about writing code of BTNode:
1. in the beginning of the code, we need to write a if condition of node is empty.
2. in writing the code, it is easier to consider the node.left and node.right as two parts.
3.list method is a good method to use when doing delete or insert.
I still think BTNode is hard, and I hope I could do better in learning materials and also do good in the final exam.

没有评论:
发表评论