Traverse a Binary Tree - Introduction 二叉树的遍历

Pre-order Traversal 前序遍历

Pre-order traversal is to visit the root first. Then traverse the left subtree. Finally, traverse the right subtree.

In-order Traversal 中序遍历

In-order traversal is to traverse the left subtree first. Then visit the root. Finally, traverse the right subtree.

Post-order Traversal 后序遍历

Post-order traversal is to traverse the left subtree first. Then traverse the right subtree. Finally, visit the root.

Recursive or Iterative //递归和迭代

Try to practice the three different traversal methods in our after-article exercise. You might want to implement the methods recursively or iteratively. Implement both recursion and iteration solutions and compare the differences between them.

我的理解:不管是怎么样的遍历,都是从左到右的普遍规则,这里所谓的 前、中、后,都是指root(根),
前:访问每个二叉树时,根第一个去访问,
中:访问二叉树的时候,根是第二个去访问
后:访问每个二叉树时,根是最后一个去访问

==
2018年10月7日21:10:45

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值