Binary Tree Operations(I)

There are two kinds of traversal for (binary) trees: Depth First Search(DFS) and Breadth First Search(BFS). Depth First Search visits the tree by proceeding deeper and deeper until it reaches the leaf nodes, including pre-order, in-order, post-order tree traversal. DFS uses a data structure called Stack.

Breadth First Search is the most natural solution for level-order traversal, since it visits the nodes level by level. BFS requires the use of a data structure called Queue, which is a First In First Out (FIFO) structure.

For the complete C++ source code used in this article, please refer to: https://github.com/bo-yang/BinaryTree.

  1. Data Structure
  2. Build Binary Tree
  3. Preorder Traversal
  4. Inorder Traversal
  5. Postorder Traversal
  6. Breadth First Traversal
  7. Zigzag Traversal
  8. Binary Tree Comparison

Data Structure

- See more at: http://bo-yang.github.io/2014/05/26/binary-tree-traversal/#sthash.jgL6Z8yC.dpuf

http://bo-yang.github.io/2014/05/26/binary-tree-traversal

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值