A red-black (RB) tree is a data structure with red and black nodes coloration. The red and black color of nodes make up the principal component for balancing a RB tree. A balanced tree has an equal number of black nodes on any simple path. But when a black leaf node is deleted, a double-black (DB) node is formed, thus, causing a reduction in black heights and the tree becomes unbalanced. Rebalancing a RB tree with a DB node is a fairly complex process. Teaching and learning the removal of DB nodes is also challenging. This paper introduces a simplified novel method which is a symbolic-algebraic arithmetic procedure for the removal of DB nodes and the rebalancing of black heights in RB trees. This simplified approach has enhanced student learning of the DB node removal in RB trees. Feedback from students showed the learnability, workability and acceptance of the symbolic-algebraic method in balancing RB trees after a delete operation.
翻译:红黑树是一种具有红色和黑色节点着色特性的数据结构。节点的红黑颜色构成了平衡红黑树的主要组成部分。平衡树要求任意简单路径上的黑色节点数量相等。但当删除黑色叶节点时,会产生双黑节点,导致黑色高度降低,树变得不平衡。对含有双黑节点的红黑树进行再平衡是一个相当复杂的过程。双黑节点的删除教学与学习同样具有挑战性。本文提出了一种简化的创新方法,即用于删除双黑节点并重新平衡红黑树黑色高度的符号代数算术程序。这种简化方法提升了学生对红黑树中双黑节点删除的学习效果。学生反馈表明,该符号代数方法在删除操作后平衡红黑树方面具有可学性、可操作性和可接受性。