[Bona1122] 25.02.06 #37
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[트리]
문제를 풀면서 나온 트리의 종류와 특징을 정리해봤습니다.
트리의 기본 특징
1. 이진트리: 트리의 각 노드가 최대 2개의 자식을 갖는 트리
루트노드를 언제 처리하는 지에 따라 순회방법이 3가지가 있다.
2. 완전이진트리: 마지막 레벨을 제외한 모든 레벨이 왼쪽부터 완전히 채워진 트리
3. 이진검색트리
이진트리의 모든 노드에서
왼쪽 서브트리 값 < 노드의 값 < 오른쪽 서브트리의 값을 만족하는 트리📌 푼 문제
📝 간단한 풀이 과정
트리 순회 기본
이진 트리 입력되면, 전위순회/중위순회/후위순회 출력하는 문제였는데
클래스를 이용해서 이진트리를 입력받는 것과
map을 활용해서 이진트리를 입력받는 것 두가지로 구현해봤습니다. (key를 노드값으로, value를 [left, right] 배열로 저장)
클래스
완전 이진 트리
트리의 부모 찾기
트리
이진탐색트리
트리와 쿼리
트리의 순회