
난이도: ★☆☆☆☆ • solved on: 2025-12-05

자료구조
알고리즘/기법
핵심 키워드
- 문제 분해
- root가 null이면 더 이상 방문할 노드가 없으므로 즉시 return 한다.
- In-order 순서:
(1) 왼쪽 노드 방문 → (2) 현재 루트 출력 → (3) 오른쪽 노드 방문
핵심 로직 흐름
inOrder(root): if root is null → return inOrder(root.left) print root.data + " " inOrder(root.right)예외 처리
- null 노드 체크는 필수
public static void inOrder(Node root) {
if (root == null) {
return;
}
if (root.left != null) {
inOrder(root.left);
}
System.out.print(root.data + " ");
if (root.right != null) {
inOrder(root.right);
}
}