当前位置:首页 > IT笔试面试 - 图文
treeStack.pop(); p= p->pRight; } } }
//非递归 后序
void postOrder(BTNode* pRoot) {
if(pRoot ==NULL) return;
std::stack
while(p !=NULL) {
treeStack.push(p); nodeState.push(0); p= p->pLeft; }
while(!treeStack.empty()) {
p= treeStack.top();
while(p->pRight!= NULL &&nodeState.top() == 0) {
nodeState.pop(); nodeState.push(1); p= p->pRight;
while(p !=NULL)
37
{
treeStack.push(p); nodeState.push(0); p= p->pLeft; }
p= treeStack.top(); }
p= treeStack.top(); printf(\, p->value); treeStack.pop(); nodeState.pop(); } }
38
共分享92篇相关文档