Binary Search Tree--Data Structure
来源:互联网 发布:苹果笔记本软件下载 编辑:程序博客网 时间:2024/05/22 16:53
Hash table
RangeSearch: impossible
NearestNeighbors: impossible
Insert: O(1)
Delete: O(1)
Array:
RangeSearch: O(n)
NearestNeighbors: O(n)
Insert: O(1)
Delete: O(1)
Sorted Array:
RangeSearch: O(logn)
NearestNeighbors: O(logn)
Insert: O(n)
Delete: O(n)
Linked List:
RangeSearch: O(n)
NearestNeighbors: O(n)
Insert: O(1)
Delete: O(1)
Search Tree Property
X’s key is larger than the key of any descendent of its left child, and smaller than the key of any descendant of its right child.
Operations:
Find(k,R)
if R.Key=k:
return R
else if R.Key>k:
return Find(k,R.Left)
else if R.Key<k:
return Find(k,R.Right)
Find (modified)
else if R.Key>k:
if R.Left!=null:
return Find(k,R.Left)
return R
Next(N)
if N.Right!=null:
return LeftDescendant(N.Right)
else:
return RightAncestor(N)
LeftDescendant(N)
if N.Left=null
return N
else:
return LeftDescendant(N.Left)
RightAncestor(N)
if N.Key<N.Parent.Key
return N.Parent
else:
return RightAncestor(N.Parent)
RangeSearch(x,y,R)
L←∅
N ←Find(x,R)
while N.Key≤y
if N.Key≥x:
L ←L.Append(N)
N ←Next(N)
return L
Insert(k,R)
P ←Find(k,R)
Add new node with keykas child of P
Delete(N)
if N.Right=null:
Remove N, promoteN.Left
else:
X ←Next(N)
\\ X.Left=null
Replace N byX, promoteX.Right
RotateRight(X)
P ←X.Parent
Y ←X.Left
B ←Y.Right
Y .Parent←P
P.AppropriateChild←Y
X.Parent←Y, Y.Right←X
B.Parent←X, X.Left←B
- Binary Search Tree--Data Structure
- Data Structure: Binary Search
- Data Structure:Binary Tree
- Data Structure: Binary Index Tree
- [Data Structure][Tree][Binary Tree]POJ 2255----Tree Recovery
- Data Structure: Tree
- data structure -- tree
- Basic Tree--Data Structure
- AVL tree--Data Structure
- Data Structure -Tree
- Data structure of tree
- Data Structures (Weiss) Chapter 4: Binary Search Tree C++
- Data Structure: How to traversal Binary Tree Iteratively (Preorder, Inorder and Postorder)
- search - binary search/sort tree
- Implement Binary Search Tree
- Binary Search Tree
- binary search tree
- Binary Search Tree
- 寒武纪一面
- Fragment的一个简单实现+EditText的监听事件
- TensorFlow深度学习,一篇文章就够了
- mysql高可用MHA
- STM32串口中断卡死主循环问题分析
- Binary Search Tree--Data Structure
- java使用链表实现队列
- QL的四种连接-左外连接、右外连接、内连接、全连接
- kbengien(1)
- Faster R-CNN的训练过程的理解
- java == vs equals
- FCC个人解题思路分享(2): 找出能被两个给定参数和它们之间的连续数字整除的最小公倍数。
- 下载eclipse方式
- Java:二维数组(上)