Advanced Data Structures and Implementation
2018-01-02 16:02
423 查看
12.1 Top-Down Splay Trees
An example of the top-down splaying algorithm is shown in Figure 12.4.
How to insert an item into a tree?
A new node is allocated(if necessary), and if the tree is empty, a one-node tree is created. Otherwise, we splay root around the inserted value x. If the data in the new root is equal to x, we have a duplicate; instead of reinserting x, we preserve newNode for a future insertion and return immediately. If the new root contains a value larger than x, then the new root and its right subtree become a right subtree of newNode, and the root’s left subtree becomes the left subtree of newNode.The deletion in spray trees is easy, because a splay will place the target of the deletion at the root.
12.2 Red-Black Trees
Operations on red-black trees take O(logN) time in the worst case. And compared with AVL trees, a careful nonrecursive implementation can be done relatively effortlessly.A red-blace tree is a binary search tree with the following coloring properties:
1. Every node is colored either red or black.
2. The root is black.
3. If a node is red, its children must be black.
4. Every path from a node to a null reference must contain the same number of black nodes.
A consequence of the coloring rules is that the height of a red-black tree is at most
2log(N+1).
12.2.1 Bottom-up Insertion
相关文章推荐
- !!!Chapter 12 Advanced Data Structure and Implementation
- Implementation codes of Data Structures and Algorithm Analysis in C (1)
- If advanced algorithms and data structures are never used in industry, then why learn them?
- Data Structures and algorithm analysis—1.2.4&1.2.5Modular Arithmeti&The P Word(数据结构—模数运算&P字)
- 开始读《Data Structures and the Java Collections Framework》
- Data Structures and Algorithm Analysis in C 学习之List反转
- Data Types and Data Structures (数据类型和数据结构)
- Data Structures and Algorithms
- Data Structures and Algorithms in Java
- 基于Problem Solving with Algorithms and Data Structures using Python的学习记录(6-1)——Tree
- Data.Structures.and.Algorithms数据结构电子书最新
- Advanced Data Structures
- Data Structures And Problem Solving Using Java (Fourth Edition)中译版(Java 常见异常篇)
- DATA STRUCTURES AND ALGORITHMS USING C#.
- What is the difference between Simple, Advanced and Parameter data sets?
- Pythonic Data Structures and Algorithms(Array 3)
- Sams Teach Yourself Data Structures and Algorithms in 24 Hours
- Data Structures and Algorithm Analysis in C, Second Edition(《数据结构与算法分析》C语言版 第二版)——Mark Allen Weiss
- Data Structures and Algorithm Analysis in C (数据结构与算法分析) 读书总结
- 《Data Structures and Algorithm Analysis in Java》Second Edition中文版笔记