2013年4月24日
摘要: 二叉树非递归遍历,可以采用堆栈实现,也可以采用非堆栈用指针实现。感觉堆栈实现很像递归实现,只是要自己把节点压入堆栈,弹出堆栈。非堆栈实现也有两种方法,可以在节点结构中添加标志位以显示当前节点是否已经被遍历过,也可以不用标志位,只用指针表示。这里实现了采用堆栈方式和非堆栈非标志位两种方法。View Code 1 #include <iostream> 2 #include <stack> 3 #include <ctime> 4 #include <random> 5 6 using namespace std; 7 8 template<c 阅读全文
posted @ 2013-04-24 15:14 blue firmament 阅读(190) 评论(0) 推荐(0) 编辑