二叉树
Deshun_Deng
One often meets his destiny on the road he takes to avoid it ^_^
展开
-
二叉树 Python的一些操作
例如我想创建如下的二叉树,该怎么办呢? 所幸的是Python中提供了像c语言里面的结构一样的东西,那么这个二叉树的结构就可以用类来实现,首先创建一个类: class Node: def __init__(self, val): self.val = val self.left = None self.right = None...原创 2018-09-13 16:44:04 · 451 阅读 · 0 评论 -
二叉树的中序遍历和后序遍历
class Node: def __init__(self, val): self.val = val self.left, self.right = None, None class Tree: def create_tree(self, pre, mid): if pre: root_val = pre[0] root_val_index_mid = mid.in...原创 2018-12-03 11:07:11 · 177 阅读 · 0 评论