Inserting and Deleting of Red-Black Trees
For I hate to remember so many cases, like RRr, RLb, RLr, following are some in-order methods covering every case for operations in Red-Black Trees.
Inserting:
1. Find Uncle.
2. If uncle is red, change the colors of parent, uncle, and grandparent.
3. If black, rotate to balanced tree, and make the second level RED.
Deleting:
1. Find Sibling’s red descendant (including itself having lowest priority, inner path having highest priority, and outer path).
2. If inner path, change to balanced tree. If outer path, rotate in sequence.
3. If fail to find red descendant, make sibling RED in order to make parent be the new deficient node, and recurse.
Explanation:
Uncle and sibling, obviously, are the other child of grandparent and parent, respectively. They are d and v in the cases following.
Rotate in sequence: the path has no polyline there, and move every node in path forward, keeping left and right positions the same.
Changing to a balanced tree, which is for inner path (or polyline path), make a node having smaller height to be the root of sub-tree.
| Rotations | Complexity |
Insert in AVL | O(1) | O(log n) |
Delete in AVL | O(log n) | O(log n) |
Insert in Red-Black Tree | O(2) | O(log n) |
Delete in Red-Black Tree | O(3) | O(log n) |
分享到:
相关推荐
在IT领域,数据结构是编程基础中的重要组成部分,而链表是其中常见的一种。有序链表的插入操作是一项常见的操作,对于理解链表特性和优化算法能力有着重要意义。本问题中,我们需要在已排序的单链表中插入一个值为x...
- **Basic Editing**: Inserting, deleting, and modifying text. - **Navigation**: Moving around the editor efficiently. - **Search and Replace**: Finding and replacing text within files. - **Advanced ...
创建和插入DOM节点 学习目标 以编程方式创建DOM元素 在DOM中添加元素 使用innerHTML更新元素 更改DOM节点上的属性 从DOM中删除元素 介绍 在本实验中,您将插入,更改和删除DOM节点。 您将执行以下操作: ...
创建和插入DOM节点 学习目标 以编程方式创建DOM元素 在DOM中添加元素 使用innerHTML更新元素 更改DOM节点上的属性 从DOM中删除元素 介绍 在本实验中,您将插入,更改和删除DOM节点。 您将执行以下操作: ...
创建和插入DOM节点学习目标以编程方式创建DOM元素在DOM中添加元素使用innerHTML更新元素更改DOM节点上的属性从DOM中删除元素介绍在本实验中,您将插入,更改和删除DOM节点。... 现在,您要了解创建新节点,删除节点和...
首先,PPT talks about the management of linear lists, including creating, inserting, and deleting elements, as well as sorting and merging lists. 其次,PPT introduces the concept of arithmetic ...
FinalBIG is a viewer and editor for the BIG files of C&C Generals and Lord of the Rings: Battle for Middle Earth. It can also open and save the MEG files of Star Wars(TM): Empire at War(TM). I tried ...
- **Tree Search and Insertion**: Searching and inserting nodes in a binary tree. - **Tree Deletion**: Removing nodes while maintaining tree structure. - **Analysis of Tree Search and Insertion**: ...
binary search tree is a data structure for representing tables and lists so that accessing, inserting, and deleting items is easy. On an n-node splay tree, all the standard search tree operations ...
Chapter 13 - Inserting Data into the Table Chapter 14 - Selecting and Displaying Data Part V - User Authentication and Tracking Chapter 15 - Database-Driven User Authentication Chapter 16 - ...
With SQLMemTable you can create SQL scripts for creating tables, inserting, editing and deleting records, retrieving data by SELECT command. - Advanced search engine. SQLMemTable supports ‘LIKE‘ ...
Black phosphorus (BP), with thickness-dependent ... After inserting BCM into an Er-doped fiber ring laser, a stable dual-wavelength Q-switched state with central wavelengths of 1542.4 nm and 1543.2 nm
- **Inserting New Records:** Description of inserting new records into a database table. - **Deleting Records:** Discussion on deleting records from a database table. - **Complex Queries:** Techniques...
The “iOS UI Design” document is now a built-in Library, updated for iOS 11 and iPhone X, and makes use of our new Smooth Corners feature Individual layers can now be exported using the Command-E ...
- **Manipulating Data**: Inserting, updating, and deleting data using SQL statements within PL/SQL. #### 5. Records Records are composite data types used to store related data. This section covers: ...
updating, deleting, and selecting data in various ways; saving to different destinations; sorting and grouping results; joining tables; managing users; other database elements such as triggers, stored...
- Disk-Editor: RAW reading and writing of disks and drives (WinNT and Win9x) - RAM-Editor: can read and write virtual memory of other processes - Data-folding for better overview in RAM-Editor - ...