
2025.04.20
오늘한 내용 : 고급 자료 구조 :RED-BLACK-TREE 구현
WEEK06: 메모리 누수, 균형 이진 탐색 트리(AVL Tree, Red-Black Tree)
삭제, 배열로 끝
succesor 구할 때 서브트리의 최솟값을 찾기 위한 함수 subtree_min() 함수 사용블랙이라면? → case 1,2,3,4 따라 색 보정 진행append() 가 없기 때문에 idx를 넘겨주어 하나씩 증가해야함static size_t insert_arr(const rbtree *t, node_t* x, key_t *arr, size_t idx, const size_t n){
if (x == t->nil || idx >= n){ //n 넘으면 바로 리턴
return idx;
}
//중위 순회
idx = insert_arr(t,x->left, arr, idx, n);
arr[idx] = x->key;
idx ++;
return insert_arr(t,x->right, arr, idx, n);
}
int rbtree_to_array(const rbtree *t, key_t *arr, const size_t n) {
//idx 0부터 시작
size_t filled = insert_arr(t, x, arr, 0, n);
}
const?const는 “변경 불가능”이라는 뜻의 타입 한정자(type qualifier)