
剑指Offer
学习不易
直到有一天,可以和你并肩站立
展开
-
二叉树创建、前中后序遍历、节点数、叶子节点数、深度、交换左右子树代码实现
文章目录链式二叉树(递归)顺序二叉树(递归)链式二叉树(非递归)顺序二叉树(非递归) 链式二叉树(递归) #include<iostream> #include<stack> #include<queue> using namespace std; template<class T> struct BiNode { T data; BiNode<T>* lchild; BiNode<T>* rchild; }; template&原创 2021-03-05 14:53:16 · 410 阅读 · 0 评论 -
剑指Offer 简单题2(树)
JZ18 二叉树的镜像 题目描述 操作给定的二叉树,将其变换为源二叉树的镜像。 输入 {5,3,7,2,4,6,8},3 返回值 {8,10,6,11,9,7,5} TreeNode* Mirror(TreeNode* pRoot) { TreeNode* temp; if (pRoot == NULL) return NULL; else { temp = pRoot->left; pRoot->left原创 2021-03-05 13:59:19 · 148 阅读 · 0 评论