Binary Tree And Divide Conquer
Last updated
Was this helpful?
Last updated
Was this helpful?
:
A Complete Binary Tree (CBT) is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.
对于一颗二叉树,假设其深度为d(d>1)。除了第d层外,其它各层的节点数目均已达最大值,且第d层所有节点从左向右连续地紧密排列,这样的二叉树被称为完全二叉树;
换句话说,完全二叉树从根结点到倒数第二层满足完美二叉树,最后一层可以不完全填充,其叶子结点都靠左对齐。
:
A Perfect Binary Tree(PBT) is a tree with all leaf nodes at the same depth. All internal nodes have degree 2.
二叉树的第i层至多拥有个节点数;深度为k的二叉树至多总共有个节点数,而总计拥有节点数匹配的,称为“满二叉树”;
A Full Binary Tree (FBT) is a tree in which every node other than the leaves has two children.
换句话说,所有非叶子结点的度都是2。(只要你有孩子,你就必然是有两个孩子。)
DFS in Binary Tree
Preorder / Inorder / Postorder
Introduce Divide Conquer Algorithm
Non-recursion vs Traverse vs Divide Conquer
BFS in Binary Tree
Binary Searh Tree
Insert / Remove / Find / Validate
Preorder前序遍历○1245 3根左右
●Inorder中序遍历 ○42513左根右
●Postorder后序遍历○452 31左右根
Traverse vs Divide Conquer
They are both Recursion Algorithm
Result in parameter vs Result in return value
Top down vs Bottom up
BST 的遍历时间复杂度就是O(n)
平衡平衡二叉树定义(balanced Binary Tree)
高度平衡二叉树是每一个节点的两个字数的深度差不能超过1
用前序和中序建树105
用后序和中序建树106
数组构建BST 108
链表构建BST 109
前序 144
中序 94
后序 145
层次 102 103 107
求深度 104
是否平衡是平衡树 110
最小深度 111
判断BST是否合法 98
恢复BST 99
BST实现迭代:173(用到某一遍历)