RED = 1
BLACK = -1
int value
Node parent
Node left
Node right
int color
(1 : RED, -1 : BLACK)boolean hasExtraBlack
- default color : RED
- default hasExtraBlack : false
int findBrotherColor()
int findSide()
--> 1(right), -1(left), 0(root)int hasRedChild()
--> 1(right), -1(left), 0(없다.), 2(양쪽)
- nil 노드는 있게끔 구현
Node root
int size
boolean isEmpty()
int size()
void insert(int value)
boolean contains(int value)
void delete(int value)
void rotateLeft(Node node)
--> Node 간 링크만 수정void rotateRight(Node node)
--> Node 간 링크만 수정int countBlack(Node tree)
--> subtree의 black 수 계산 (자기 자신 제외 + nil 노드 포함)
- 자식 두개 일 때 삭제하는 과정에서 왼쪽 서브트리에서 가져온다.
- 재귀로 구현하는 것
- insert : 형제도 red일 때
- delete : doublyblack의 형제도 검은색일 때