Question: RBTNode is a Java class for a node in a red - black tree. Which is the correct implementation of the RBTNode class's areBothChildrenBlack (

RBTNode is a Java class for a node in a red-black tree. Which is the correct implementation of the
RBTNode class's areBothChildrenBlack() method?
boolean areBothChildrenBlack(){
if (left.isRed()|| right.isRed()){
return false;
}
return true;
}
boolean areBothChildrenBlack(){
if (left.isRed() && right.isRed()){
return false;
}
return true;
}
boolean areBothChildrenBlack(){
if (left == null || left.isRed()){
return false;
}
if (right == null || right.isRed()){
return false;
}
return true;
}
boolean areBothChildrenBlack(){
if (left != null && left.isRed()){
return false;
}
if (right != null && right.isRed()){
return false;
}
return true;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!