Binary search tree 有着 Ordered Array 和 Linked List的优点:search item O(logn) , insert and delete O(1) ,两者结合之后,得到特性:所有操作都在O(logn)之内可以实现。
BST 高度: root 0; 方便计算叶节点数目。 # Leaf=2^H
几种定义:
full BT: each node has zero or two children
complete BT : is completely filled (left to right) with possible exception of the bottom level, (右边可以连续缺少)
BST: any node given K, 左子树 所有都比K小,右子树所有都比K大。
Node :-key,-value,-Node left, -Node right
search:
public boolean find(int Key){,,,,} default you can find it, use Node Pointer Current for traverse.
Insert:
step1:find the place to insert
step2:insert but we should keep a parent pointer
Deletion:
complicated:
aspect1: