Tree Flashcards
Complete Binary Tree :第 i 层最多有多少个节点?
Perfect Binary Tree : 高度为h的树会有多少个节点?
如何定义 二叉树的节点?
Basic Terminologies in Binary Tree :
Binary Tree : Properties
Binary Tree types : Full Binary Tree
Binary Tree types : Complete Binary Tree
Binary Tree types : Perfect Binary Tree
Binary Tree types : Degenerate Binary Tree
Binary Tree types : Balanced Binary Tree
Binary Search Tree : define Tree structure
Binary Search Tree : newNode
Binary Search Tree : Insert
Binary Search Tree :find_minimum
Binary Search Tree : find _maximum
Binary Search Tree : height
Tree : Time Complexity && Space Complexity
考试题:根据前序、中序遍历画出二叉树
考试题:根据后序、中序遍历画出二叉树
前序、中序、后序遍历:
level_lraversal : how it works
Hint:
1.isempt
2.create queue & temp
3.enqueue(root)
4.while
{
temp = dequeue (queue)
…..
}
5.free
level_Traversal : create 3 ADT
Hint: node,queue node, queue
level_lraversal - create queue containing node : Isempty
level_lraversal - create queue containing node : create queue
level_lraversal - create queue containing node : enqueue
- temp
- Null: front = temp
- ! Null: rear & temp
level_Traversal - create queue containing node : dequeue
- isempty
2.temp (delete)
3.data(return)
4.front (move)
5.free
6.return
后序遍历(Post order):层看法失效的情况,但是右侧法依然可以
原因:最后一层的上方有两个父母
Tree : Preorder Traversal
Tree : Inorder Traversal
Tree : Postorder Traversal
Binary Search Tree : Is_binarysearch_tree (With no biggest and smallest datas)
Hint
1.exit condition
2.false condition
3.recursion
Binary Search Tree : Is_binarysearch_tree (With biggest and smallest datas)
Hint:
1.exit condition
2.false condition
3.recursion
Binary Search Tree : Delete
Hints:
Part 1 : exit condition
Part 2 : Recursion part
1.search (also plays a role in deleting nodes with 2 children)
2.delete nodes with no child or one child
3.delete nodes with 2 children:
1️⃣find the smallest node in the right sub tree
2️⃣delete (substitute the deleted node)
3️⃣link the rest subtree
Binary Search Tree : Find_inorder_successor
Hint:
Part 1: exit condition
Part 2: recursion
1️⃣right child exist
reach deepest
2️⃣ right child doesn’t exist
1.root > data
accessor ,root
2.root < data
root
3.root = data
return
二叉树的性质总结 :
补充 “ 树的性质 : 节点数 = 分支数 + 1 ”
例题 :树求叶子节点个数
hint : 完全二叉树度为0的节点数 = 度为2的节点数加1
例题 :求树的高度
例题 :满__叉树第n层的节点数
Hint :深度从1开始
例题 :哈夫曼树的性质
例题 :树的性质 – 节点数 = 分支数 + 1
树 ——> 二叉树 的转换方法 :
二叉树 ——> 树 的转换方法 :
森林 ——> 二叉树 的转换方法 :
二叉树 ——> 森林 的转换方法 :
例题 :画线索二叉树
hint : 没有左孩子,连前驱;没有右孩子,连后继。两个都没有,就都要连
AVL Tree : right & left rotation
AVL Tree : LL & RR & LR & RL
Categories of Tree : how to distinguish them?
What does depth and height mean?
;
What’s the difference between them?
depth : The number of edges in the path from root node to the selected node.
height : The number of edges in the longest path connecting the selected node to any leaf node .