论文标题

通过教学上有高效但有效的删除算法重新访问2-3棵红黑树:寻求平等的删除算法

Revisiting 2-3 Red-Black Trees with a Pedagogically Sound yet Efficient Deletion Algorithm: The Parity-Seeking Delete Algorithm

论文作者

Ghiasi-Shirazi, Kamaledin, Ghandi, Taraneh, Taghizadeh, Ali, Rahimi-Baigi, Ali

论文摘要

红黑(RB)树是平衡二进制搜索树最有效的变体之一。但是,他们总是被指责为太复杂,难以解释,并且不适合教学目的。在Guibas&Sedgewick(1978)的开创性工作中,已经考虑了2-3和2-3-4变体RB树的变体,但是由于插入算法中的旋转数量较高,对前者的进一步研究被放弃了。 Sedgewick(2008)提出了一个2-3个RB树的变体,即。左倾的红黑(LLRB)树,其中红色链接仅限于左子女,并提出了简明的递归插入和删除算法。但是,LLRB的自上而下的删除算法仍然非常复杂且效率高。在本文中,我们重新考虑了2-3棵红黑树,其中两个节点的孩子都不是红色的。我们提出了一种寻求奇偶校验的删除算法,其基本思想是使不足的子树与其同胞相提并论:通过修复缺陷的子树或通过使同胞缺陷以及将缺陷升至亲本节点。有趣的是,拟议的寻求平价删除算法也适用于2-3-4 RB树。我们的实验表明,2-3个RB树几乎与RB树一样高,并且比LLRB树快两倍。此外,带有拟议的均等删除算法的RB树具有相同数量的旋转,并且几乎相同的运行时间与经典删除算法相同。虽然提出的均等删除算法非常有效,但易于理解,适合教学目的。

Red-black (RB) trees are one of the most efficient variants of balanced binary search trees. However, they have always been blamed for being too complicated, hard to explain, and not suitable for pedagogical purposes. In the pioneering work of Guibas & Sedgewick (1978), both 2-3 and 2-3-4 variants of RB trees had been considered, but further study of the former had been abandoned due to the higher number of rotations in the insert algorithm. Sedgewick (2008) proposed a variant of 2-3 RB trees, viz. left-leaning red-black (LLRB) trees, in which red links are restricted to left children and proposed concise recursive insert and delete algorithms. However, the top-down deletion algorithm of LLRB is still very complicated and highly inefficient. In this paper, we reconsider 2-3 red-black trees in which both children of a node cannot be red. We propose a parity-seeking delete algorithm with the basic idea of making the deficient subtree on a par with its sibling: either by fixing the deficient subtree or by turning the sibling deficient as well, ascending deficiency to the parent node. Interestingly, the proposed parity-seeking delete algorithm works for 2-3-4 RB trees as well. Our experiments show that 2-3 RB trees are almost as efficient as RB trees and twice faster than LLRB trees. Besides, RB trees with the proposed parity-seeking delete algorithm have the same number of rotations and almost identical running time as the classical delete algorithm. While being extremely efficient, the proposed parity-seeking delete algorithm is easily understandable and suitable for pedagogical purposes.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源