程序员面试题精选100题(11)-求二元查找树的镜像[数据结构](2)
发布时间:2019-09-22整理:admin阅读:
BSTreeNode *pNode = stackTreeNode.top();
stackTreeNode.pop();
// swap the right and left child sub-tree
BSTreeNode *pTemp = pNode->m_pLeft;
pNode->m_pLeft = pNode->m_pRight;
pNode->m_pRight = pTemp;
// push left child sub-tree into stack if not null
if(pNode->m_pLeft)
stackTreeNode.push(pNode->m_pLeft);
// push right child sub-tree into stack if not null
if(pNode->m_pRight)
stackTreeNode.push(pNode->m_pRight);
}
}
欢迎分享转载→ 程序员面试题精选100题(11)-求二元查找树的镜像[数据结构](2)