2015年3月2日星期一

week7: Recursion

In the Week 7, we have learnt about the BTNode, which is similar with  class Tree. BTNode also have root and leaves. However, there is only two children with right and left instead of the many children. 
In many definition under the class BTNode, they need to apply to recursion in their code. We should consider the recursion of right and left children. For example, def list_longest_path(node) in class BTNode in lab06. We find the list_longest_path(node.left) and find the list_longest_path(node.right). Then, we compare the longer one between left and right children. Eventually, we can return the longest one in all these nodes. This is the traditional recursion. 

没有评论:

发表评论