2013年6月7日

摘要: 前序,中序,后序遍历的非递归实现。层次遍历,从上到下或从下到上,从左到右或从右到左,只输出叶子节点,只输出某一层等等。1、代码: 1 void PreOrder(BinaryTreeNode* root) 2 { 3 if (!root) return; 4 stack<BinaryTreeNode*> nodes; 5 while (root != NULL || !nodes.empty()) 6 { 7 if (root != NULL) 8 { 9 cout << root->m_nValue <<... 阅读全文
posted @ 2013-06-07 21:00 月moon鸟 阅读(169) 评论(0) 推荐(0) 编辑

导航