树
二叉树的实现及遍历
# -*- coding:utf-8 -*-
'''
用Python实现树,并遍历。
'''
class Node():
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def depth(root):
if root is None:
return 0
else:
return 1 + max(depth(root.left), depth(root.right))
#前序遍历
def pre_order