deleteMin Left Leaning read black tree need more explanation

烈酒焚心 提交于 2020-06-17 13:07:32

问题


I'm reading Left Leaning Red Black Tree in algorithms 4th edition, by Robert Sedgewick. I spent several days trying to understand the deleteMin as a warmup to understanding delete and this is my final question in my head about deleteMin.

    public void deleteMin()
    {
        root = deleteMin(root);
        root.color = BLACK;
    }
    private Node deleteMin(Node h)
    {
        if (h.left == null) return null;
        if (!isRed(h.left) && !isRed(h.left.left))
            h = moveRedLeft(h);
        h.left = deleteMin(h.left);
        return fixUp(h);
    }

when h.left and h.left.left are both black, call h=moveRedLeft(h);
The question is, how can we assert that the node b is red, as the picture shows?

来源:https://stackoverflow.com/questions/62134053/deletemin-left-leaning-read-black-tree-need-more-explanation

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