返回
介绍了树的基本定义和特点,并使用 Python 实现了一个简单的树结构(TreeNode, Tree),演示了多种树的操作:前序遍历(循环/递归)、后序遍历(循环/递归)、层次遍历、求深度、求节点数、求叶子数、求最低公共祖先节点以及求任意两节点距离。
python
tree
data structures
algorithm
traversal
preorder
postorder
level order
lowest common ancestor