二叉树四种遍历方法
class Node ( object ) : def __init__ ( self , item ) : self . item = item self . lchild = None self . rchild = None class Tree ( object ) : """二叉树""" def __init__ ( self ) : self . root = None def add ( self , item ) : node = Node ( item ) if self . root is None : self . root = node return None queue = [ self . root ] while queue : cur = queue . pop ( 0 ) if cur . lchild is None : cur . lchild = node return None else : queue . append ( cur . lchild ) if cur . rchild is None : cur . rchild = node return None else : queue . append ( cur . rchild ) def breadth_travel ( self ) : """广度遍历""" queue =