/** * @brief If sibling is black and its both children are black, perform recoloring. * @param t is the tree root. * @param n is the node at which deletion is taking place. */ void delete_case4(rbtree t, node n) { if (node_color(n->parent) == RED && node_color(sibling(n)) == BLACK && node_color(sibling(n)->left) == BLACK && node_color(sibling(n)->right) == BLACK) { sibling(n)->color = RED; n->parent->color = BLACK; } else delete_case5(t, n); }
static void delete_case4(L_RBTREE *t, node *n) { if (node_color(n->parent) == L_RED_NODE && node_color(sibling(n)) == L_BLACK_NODE && node_color(sibling(n)->left) == L_BLACK_NODE && node_color(sibling(n)->right) == L_BLACK_NODE) { sibling(n)->color = L_RED_NODE; n->parent->color = L_BLACK_NODE; } else { delete_case5(t, n); } }
void delete_case4(struct rbtree* t, struct rbtree_node* n) { if (get_color(n->parent) == RB_RED && get_color(sibling(n)) ==RB_BLACK && get_color(sibling(n)->left) ==RB_BLACK && get_color(sibling(n)->right) == RB_BLACK) { sibling(n)->color =RB_RED; //sibling's two son is black ,so it can changed to red n->parent->color = RB_BLACK; } else delete_case5(t, n); }
void delete_case4(rb_node* n, rb_tree* tree) { rb_node* s = sibling(n); if ((n->parent->color == RED) && (s->color == BLACK) && (s->left->color == BLACK) && (s->right->color == BLACK)) { s->color = RED; n->parent->color = BLACK; } else { delete_case5(n, tree); } }
static inline void delete_case4(struct RBTREE_TYPENAME* target, struct RBTREE_NODE* P, struct RBTREE_NODE* N, struct RBTREE_NODE* S) { if ((P->color == RED) && (S->color == BLACK) && (S->left == NULL || S->left->color == BLACK) && (S->right == NULL || S->right->color == BLACK)) { S->color = RED; P->color = BLACK; } else delete_case5(target, P, N, S); }
void Tree::delete_case4() { //if parent is red and siblings family is black //we add another black to current nodes path by making parent red //and removing a black from siblings path if(parent->red && !(sibling()->red) && !(sibling()->left->red) && !(sibling()->right->red)) { sibling()->red = true; parent->red = false; return; } else delete_case5(); }