Lecture 11 Augmenting Data Structures
来源:互联网 发布:淘宝做网站靠谱吗 编辑:程序博客网 时间:2024/04/27 19:18
Take the basic data structure and add new operations on it.
Dynamic order statistics:
OS-Select(i)--returns ith smallest item in dynamic set.
OS-Rank(x)--returns rank of x in sorted order.
Idea: keep sub-tree sizes in nodes of RB-tree.
Size[x]=size[left[x]]+size[right[x]]+1
Trick: use sentinel (dummy record) for nil. Size[nil]=0
Ex. OS-Select(root,5) --> ptr to “H”
Analysis: O(logn)
OS-Rank in CLRS
Q: Why not keep ranks in nodes instead of sub-tree sizes?
A: Hard to maintain when RB-tree is modified.
Modifying ops: Insert Delete
Strategy: Update subtree sizes when inserting or deleting.
Ex. Insert “K”. But must also handle rebalancing.
---RB color changes: no effect
---rotations: look at children and fix up in O(1) time
Ex.
Insert,Delete still O(logn) time.
Data-structure augmentation
Methodology.(Ex. OStrees)
数据结构 1.Choose underlying data structure(red-black tree);
附加信息 2.Determine additional info(subtree sizes);
保持信息 3.Verify that info can be maintained for modify operations(insert and delete---rotations);
新的操作 4.Develop new operations that use info(OS-Select, OS-Rank)
Usually, must play with interactions between steps.
Interval trees
Maintain a set of intervals e.g. Time intervals
Query: Find an interval in the set that overlaps a given query interval.
Methodology:
1. red-black tree keyed on low endpoint;
2. Store in node the largest value m in the sub-tree rooted at that node;
3. Modifying ops
Insert: Fix m's on way down.
But, also need to handle rotations. Fixing up m's during rotation takes O(1) time.
=> Insert time=O(logn), Delete similar.
4. New operations.
Ex. [14,16] -> [15,18]
[12,14]-> nil
Time=O(logn)
List all overlaps: O(klogn) “output sensitive”: the running time depends upon #outputs.
Best to date=O(k+logn)
Correctness:
- Lecture 11 Augmenting Data Structures
- chapter 11 Data Structures
- Augmenting Existing Data structure 总结
- Data Structures
- data structures
- Data Structures
- data structures
- Data Structures
- Data Structures
- Data Structures - Immutable Data Structures
- Data Structures and Algorithms
- Data Structures Demystified
- Data Structures and Algorithms
- Disjoint-set Data Structures
- C & Data Structures
- Data Structures Demystified
- Data Structures, Suffix Trees
- Data Structures, Fall 2007
- WKWebView与js交互
- CNN感性认识(三)——为什么深层次神经网络难于训练?
- iOS ERROR ITMS-90032 : "Invalid Image Path
- Android开发NavigationView遇到的问题
- 异常断电导致HDFS文件块丢失,影响HBASE数据的问题处理
- Lecture 11 Augmenting Data Structures
- java环境变量配置
- mysql 时间日期转换函数
- C语言字符操作函数实现
- 生活小常识--吃香蕉喝雪碧会吐
- Flake8
- log4j配置解析
- LeetCode刷题【Array】 Next Permutation
- Android仿JD选择地区