Skip to content

Commit 70e5688

Browse files
committed
check btree
1 parent 7ea936f commit 70e5688

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

include/btree.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,31 +272,35 @@ namespace alg {
272272
}
273273

274274
// case 2c:
275-
// Otherwise, if both y and ´ have only t 2 1 keys,
276-
// merge k and all of ´ into y, so that x loses both k and the
277-
// pointer to ´, and y now contains 2t c 1 keys.
278-
// Then free ´ and recursively delete k from y.
275+
// Otherwise, if both y and z have only t-1 keys,
276+
// merge k and all of z into y, so that x loses both k and the
277+
// pointer to z, and y now contains 2t - 1 keys.
278+
// Then free z and recursively delete k from y.
279279
if (y->n == T-1 && z->n == T-1) {
280280
// merge k & z into y
281281
y->key[y->n] = k;
282282

283283
int j;
284-
for (j=0;j<z->n;j++) { // merge n keys, k already in
284+
for (j=0;j<z->n;j++) { // merge keys of z
285285
y->key[y->n+j+1] = z->key[j];
286286
}
287-
for (j=0;j<z->n+1;j++) { // merge n+1 childs
288-
y->c[y->n+j+1] = z->key[j];
287+
for (j=0;j<z->n+1;j++) { // merge childs of z
288+
y->c[y->n+j+1] = z->c[j];
289289
}
290-
// mark free this node
290+
291+
// mark free z
291292
z->flag |= MARKFREE;
292293
y->n = y->n + z->n + 1; // size after merge
293294
WRITE(z.get());
294295
WRITE(y.get());
295296

296-
// shift x
297-
for (j=i;j<x->n-1;j++) {
297+
for (j=i;j<x->n-1;j++) { // delete k from node x
298298
x->key[i] = x->key[i+1];
299299
}
300+
301+
for (j=i+1;j<x->n;j++){ // delete pointer to z --> (i+1)th
302+
x->c[i] = x->c[i+1];
303+
}
300304
x->n = x->n - 1;
301305
WRITE(x);
302306

0 commit comments

Comments
 (0)