bool left = false;
while (x != NULL) {
y = x;
- left = cmp(node, x) < 0;
+ left = cmp(x, node) < 0;
if (left)
x = x->left;
else
while (x != NULL) {
int c = cmp(x, key);
if (c < 0)
- x = x->right;
- else if (c > 0)
x = x->left;
+ else if (c > 0)
+ x = x->right;
else
return x;
}
y = x;
int c = cmp(x, key);
if (c < 0)
- x = x->right;
- else if (c > 0)
x = x->left;
+ else if (c > 0)
+ x = x->right;
else
return x;
}