CLRS icon indicating copy to clipboard operation
CLRS copied to clipboard

B-TREE-MAX calling B-TREE-MIN

Open cgarbin opened this issue 5 years ago • 0 comments

In https://walkccc.github.io/CLRS/Chap18/18.2/, question 18.2.3, we have this:

    if x == NIL           // T is empty
        return NIL
    else if x.leaf        // x is leaf
        return x.[x.n]    // return the maximum key of x
    else
        DISK-READ(x.c[x.n + 1])
        return B-TREE-FIND-MIN(x.c[x.n + 1])

Shouldn't the last line be return B-TREE-FIND-MAX(x.c[x.n + 1]) instead?

It seems that we want to keep recursing to find the max value of the subtree. I can't find a reason to look for the minimum value at that point.

cgarbin avatar Feb 03 '20 00:02 cgarbin