Red Black Tree ~ 1 Child Deletes

隐身守侯 提交于 2019-12-06 00:18:46
templatetypedef

No, this isn't possible.

Remember, that in a red/black tree, all paths from the root of the tree off of the tree must pass through the same number of black nodes (that's one of the red/black tree invariants).

If you have a red node x with one black child y, it cannot have another red child (since that breaks the red/black invariant that red nodes can't have red children).

This means that a path through x to the missing child will pass through at least one fewer black node than the path through x, then to y, and then off the tree from there, breaking the red/black tree invariants.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!