인프런 커뮤니티 질문&답변
GetHeight 부분... 이렇게 작성하면 망한건가요
작성
·
260
0
int height = 0;
int maxHeight = 0;
int GetHeight(NodeRef root) {
height++;
if (root->children.empty()) {
return height;
}
for (NodeRef child : root->children) {
GetHeight(child);
if (maxHeight <= height) {
maxHeight = height;
}
height--;
}
return maxHeight;
}퀴즈
트리(Tree) 자료구조의 가장 큰 특징은 무엇일까요?
데이터가 삽입된 순서대로 정렬됩니다.
각 노드는 최대 두 개의 자식만 가질 수 있습니다.
데이터가 부모-자식 관계의 계층적인 형태로 표현됩니다.
노드 간 연결에 방향성이 없습니다.





