`
幸运虫
  • 浏览: 47565 次
  • 性别: Icon_minigender_2
  • 来自: 甘城
社区版块
存档分类
最新评论

Inserting and Deleting of Red-Black Trees

 
阅读更多
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.


RotationsComplexity
Insert in AVLO(1)O(log n)
Delete in AVLO(log n)O(log n)
Insert in Red-Black TreeO(2)O(log n)
Delete in Red-Black TreeO(3)O(log n)


0
0
分享到:
评论

相关推荐

    Inserting-an-Ordered-Table.rar_Table

    在IT领域,数据结构是编程基础中的重要组成部分,而链表是其中常见的一种。有序链表的插入操作是一项常见的操作,对于理解链表特性和优化算法能力有着重要意义。本问题中,我们需要在已排序的单链表中插入一个值为x...

    Wiley.Publishing.Fedora.Linux.Toolbox.1000+.Commands.for.Fedora.CentOS.and.Red.Hat.Power.Users.and.Red.Hat.Power.Users.2008.pdf

    - **Basic Editing**: Inserting, deleting, and modifying text. - **Navigation**: Moving around the editor efficiently. - **Search and Replace**: Finding and replacing text within files. - **Advanced ...

    fewpjs-removing-altering-and-inserting-html-lab-v-000

    创建和插入DOM节点 学习目标 以编程方式创建DOM元素 在DOM中添加元素 使用innerHTML更新元素 更改DOM节点上的属性 从DOM中删除元素 介绍 在本实验中,您将插入,更改和删除DOM节点。 您将执行以下操作: ...

    fewpjs-removing-altering-and-inserting-html-lab-online-web-sp-000

    创建和插入DOM节点 学习目标 以编程方式创建DOM元素 在DOM中添加元素 使用innerHTML更新元素 更改DOM节点上的属性 从DOM中删除元素 介绍 在本实验中,您将插入,更改和删除DOM节点。 您将执行以下操作: ...

    fewpjs-removing-altering-and-inserting-html-lab-onl01-seng-ft-041320

    创建和插入DOM节点学习目标以编程方式创建DOM元素在DOM中添加元素使用innerHTML更新元素更改DOM节点上的属性从DOM中删除元素介绍在本实验中,您将插入,更改和删除DOM节点。... 现在,您要了解创建新节点,删除节点和...

    数据结构PPT优秀资料.ppt

    首先,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 ...

    BIG文件编辑器

    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 ...

    Algorithms and Data Structures - Niklaus Wirth

    - **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**: ...

    Self-Adjusting Binary Search Trees (1985)-计算机科学

    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 ...

    PHP经典教程 PHP 5 Fast & Easy Web Development

    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 - ...

    SQLMemTable for Delphi / C++ Builder

    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‘ ...

    Switchable dual-wavelength Q-switched fiber laser using multilayer black phosphorus as a saturable absorber

    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

    Beginning PHP 5.3

    - **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...

    Sketch47破解版.永久使用.

    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 ...

    Oracle Database 10g PL-SQL Programming

    - **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: ...

    mysql-8-cookbook2018

    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...

    HxD HeX Editor 英文绿色版

    - 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 - ...

Global site tag (gtag.js) - Google Analytics