用C++写一个红黑树左旋代码
时间: 2023-02-26 09:11:09 浏览: 92
红黑树,用c++写的程序算法
这里是一个C语言实现红黑树左旋的例子:void LeftRotate(struct node *x)
{
struct node *y = x->right;
x->right = y->left;
if (y->left != NULL)
y->left->parent = x;
y->parent = x->parent;
if (x->parent == NULL)
root = y;
else if (x == x->parent->left)
x->parent->left = y;
else
x->parent->right = y;
y->left = x;
x->parent = y;
}
阅读全文