问题
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