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.
没有评论:
发表评论