随笔分类 - leetcode 二叉树篇
摘要:struct BtreeNode { int val; BtreeNode*pleft; BtreeNode*pright; } void findpath(BtreeNode*root,int target) { if(!root) { return; } vector<int>path; int
阅读全文
摘要:1.层次遍历二叉树: 从上往下的层次遍历: struct TreeNode { int val; TreeNode*pleft; TreeNode*pright; } void PrintNodeatLevel(TreeNode *root,int level) { if(!root) { retu
阅读全文
摘要://递归: 判断该树是否为平衡二叉树 方法一:调用上述函数求每个节点的左右孩子深度 [cpp] view plain copy print? bool IsBalanced(BinaryTreeNode* pRoot) { if(pRoot== NULL) return true; int nLef
阅读全文
摘要:struct node { node*pleft; node*pright; int value; } voide rebuild(char *pre,char *pmid,int len ,node**root) { //检查边界条件 if(pre==null&&pmid==null||len<=
阅读全文
摘要:概念: struct BinaryTree { int value; BinaryTree*pright; BinaryTree*pleft; } 满二叉树 完全二叉树 二叉搜索树 编程题: 实现二叉树的遍历: 递归的算法实现二叉树的遍历: 题一:树的子结构: vool hassubtree(Bin
阅读全文
浙公网安备 33010602011771号