Skip to content

Commit

Permalink
fix: docs rbtree (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwsung91 authored Feb 16, 2025
1 parent 07ee910 commit da9b7db
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions _posts/2025-02-16-red-black-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ categories: [Software engineering, Data structure]
tags: [Data structure]
render_with_liquid: false
description: "Red-black tree 개념정리 및 예시"
image:
path: img/data_structure/Red-black_tree_example.png
---

## 정의
Expand Down Expand Up @@ -34,20 +36,11 @@ description: "Red-black tree 개념정리 및 예시"

노드의 색만 바꾸어 규칙위반을 수정하는 방법

- 대상: 부모(P)와 삼촌(U)이 모두 빨강인 경우
- 조치: 부모(P)와 삼촌(U)을 검정, 조부모(G)를 빨강으로 변경
- 특징: 회전 없이 색상만 변경하여 문제를 해결하며, 필요 시 재귀적으로 상위 노드에 대해 처리

### Rotation

트리의 모양을 변경하기 위해 회전(rotation) 을 수행하는 방법
트리의 모양을 변경하기 위해 회전을 수행하는 방법

- 대상: 부모는 빨강, 삼촌은 검정일 때
- 조치:
- 노드의 위치를 조정(반대쪽 자식이면 회전하여 같은 방향으로 맞춤)
- 부모와 조부모의 색을 교환
- 조부모를 기준으로 회전하여 트리 균형을 회복
- 특징: 트리의 구조 자체를 변경하여, Recoloring 만으로는 해결되지 않는 불균형을 근본적으로 수정
![Binary_Tree_Rotation](/img/data_structure/Binary_Tree_Rotation_(animated).gif){: w="300" h="300" }

## 조정 과정

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/data_structure/Red-black_tree_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit da9b7db

Please sign in to comment.