首页 > 其他 > 详细

二叉树遍历

时间:2020-06-21 22:00:16      阅读:79      评论:0      收藏:0      [点我收藏+]

引自:https://blog.csdn.net/zhhp1001/article/details/88257018

 

技术分享图片

 

 

 技术分享图片

 

 

 技术分享图片

技术分享图片

 

 

 技术分享图片

 

 

 技术分享图片

 

 

 技术分享图片

 

 

 技术分享图片

 

 

 技术分享图片

 

 测试代码:

int main(int argc, char* argv[]) {

BinaryTreeNode* A = new BinaryTreeNode(1);
BinaryTreeNode* B = new BinaryTreeNode(2);
BinaryTreeNode* C = new BinaryTreeNode(4);
BinaryTreeNode* D = new BinaryTreeNode(7);
BinaryTreeNode* E = new BinaryTreeNode(3);
BinaryTreeNode* F = new BinaryTreeNode(5);
BinaryTreeNode* G = new BinaryTreeNode(6);
BinaryTreeNode* H = new BinaryTreeNode(8);
A->leftchild = B;
A->rightchild = E;
B->leftchild = C;
C->rightchild = D;
E->leftchild = F;
E->rightchild = G;
G->leftchild = H;
std::cout << "Pre order traversal:" << std::endl;
pre_traversal(A);
std::cout << std::endl<< "In order traversal:" << std::endl;
in_traversal(A);
std::cout << std::endl << "Post order traversal:" << std::endl;
post_traversal(A);


return 0;
}

二叉树遍历

原文:https://www.cnblogs.com/lyp1010/p/13173916.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!