我遇到了这个奇怪的错误。基本上我从书中找到了一些伪代码,并决定在我的红黑树中实现这个功能。 这是代码:
void InsertFixtUp(Node<Key,Item> * z)
{
Node<Key,Item> * y = 0;
if(z->parent != 0)
{
while (z->parent->colour==RED){ // first Error here
if (z->parent==z->parent->parent->left){
y=z->parent->parent->right;
if(y->colour==RED) {
//Case 1
z->parent->colour = BLACK;
y->colour=BLACK;
z->parent->parent->colour=RED;
z = z->parent->parent;
} else if (z==z->parent->right){
//Case 2
z=z->parent;
RotateLeft(z);
}
//Case 3
z->parent->colour=BLACK;
z->parent->parent->colour=RED;
RotateRight(z->parent->parent);
} else if (z->parent==z->parent->parent->right){
y=z->parent->parent->left;
if(y->colour==RED) {
//Case 1
z->parent->colour = BLACK;
y->colour=BLACK;
z->parent->parent->colour=RED;
z = z->parent->parent;
} else if (z==z->parent->left){
//Case 2
z=z->parent;
RotateRight(z);
}
//Case 3
z->parent->colour=BLACK;
z->parent->parent->colour=RED;
RotateLeft(z->parent->parent);
}
}
root->colour=BLACK;
}
}
第一个while循环中列表中的第一个错误是expected ‘)’ before ‘;’ token
。这个错误是什么意思?