-
자료구조 - 트리탐색인공 지능 개념 2024. 9. 22. 11:16
트리탐색
Level-order Traversal
아래그림)
동일한 깊이를 가지는 노드는 좌측부터 방문
모두 순회하면 한단계내려감 (depth부터 내려가는게 아니라)
Tree와 Subtree
subtree: tree의 부분 tree
아래그림)
전위순회 (Pre-order Traversal)
Root Node부터 간다.
Root Node => 왼쪽 Sub-Tree
아래그림)
중위순회 (In-order Traversal)
Root는 좌측우측 사이에
중위- 왼쪽 subtree, 루트노드, 오른쪽 subtree
재귀적으로 중위순회
처음: 왼쪽subtree -> 15
두번짹: 15의 왼쪽 subtree - 36
subtree의 subtree(똑같은원리 반복- 재귀)
아래그림
93의 왼쪽 subtree 중위순회
루트노드 - 93
36 => 15=> 72 => 44=> 83 => 93=> 19
아래그림)
후위순회 (root를 제일 마지막에 해서 후위순회)
왼쪽 subTree => 오른쪽 subTree => RootNode (재귀적으로 반복)
말단의 subtree로 먼저 바로간다.
'인공 지능 개념' 카테고리의 다른 글
자료구조 - 이진 탐색트리 - 중요 (0) 2024.09.22 자료구조 - 이진탐색 (Binary Search) (0) 2024.09.22 자료구조 - Heap (2) (0) 2024.09.21 자료구조 - Heap (0) 2024.09.20 자료구조 - 그래프, 트리 (0) 2024.09.20