본문 바로가기

[C++] Data Structure & Algorithm/Search Tree3

[Search Tree] Chapter 03. 레드-블랙 트리 GitHub : https://github.com/developeSHG/Data_Structure-Algorithm/commit/b5eba29eefefc411fce715e65633360368555e3e 레드-블랙 트리 구현 · developeSHG/Data_Structure-Algorithm@b5eba29 developeSHG committed Aug 11, 2023 github.com 이전 이진 탐색 트리에서 만약 한 쪽으로 데이터가 몰려 tree의 균형이 무너질 경우, 사실상 BST를 사용할 의미가 없다고 학습했다. (균형이 무너지면 그저 List랑 다를바가 없다.) 그래서 트리의 균형을 맞춰주는 알고리즘이 필요한데, 찾아보면 많은 알고리즘들(AVL)이 있지만 레드-블랙 트리도 균형을 맞춰주는 대표적.. 2023. 8. 11.
[Search Tree] Chapter 02. 이진 탐색 트리 GitHub : https://github.com/developeSHG/Data_Structure-Algorithm/commit/cff5f751dce52f7b671a3deb49a42d9c50664c94 이진 탐색 트리 · developeSHG/Data_Structure-Algorithm@cff5f75 developeSHG committed Aug 11, 2023 github.com 이전 이진 탐색 게시글에서 학습했듯, 데이터가 고정되어 있지 않고 빈번하게 삭제와 삽입을 한다면 이진 탐색은 배열을 이용하기 때문에 결국 최적화된 방법이 아니다. 그래서 Node 기반으로 데이터가 유동적으로 변화하는 Tree 구조인 이진 탐색 트리가 있다. 다른 부분은 딱히 어렵지 않지만, 꽤 고려해야 할 부분은 Delete .. 2023. 8. 11.
[Search Tree] Chapter 01. 이진 탐색 GitHub : https://github.com/developeSHG/Data_Structure-Algorithm/commit/c90552896ea75286f9c389bc80a25660530dfb8e 이진 탐색 · developeSHG/Data_Structure-Algorithm@c905528 developeSHG committed Aug 11, 2023 github.com 이진 탐색(binary search) 상황) 배열에 데이터가 정렬되어 있다 [1][8][15][23][32][44][56][63][81][91] Q) 82라는 숫자가 배열에 있습니까? 과정) 중간값을 기준으로 절반씩 나누어 범위를 좁혀나가면서 해당값을 찾는다. O(Log N) - 정렬된 배열을 이용해서 이진 탐색 가능 (number.. 2023. 8. 11.