We have been asked to implement a Red Black Tree in java, but not i'm exatcly sure how this is done. It would be really nice if anyone would comment on my node class for the r/b tree implementation. Here we go:
public class RBTnode {
public RBTnode(int key, RBTnode left, RBTnode right) {
/* this is the constructor for a root node */
color = 0;
parent = null;
key = this.key;
left = this.left;
right = this.right;
}
public RBTnode(int key, RBTnode left, RBTnode right, RBTnode parent, int color ) {
key = this.key;
color = this.color;
left = this.left;
right = this.right;
parent = this.parent;
}
int color; // 0 black, 1 red
int key;
RBTnode parent;
RBTnode left;
RBTnode right;
}