이진 검색 트리에 대한 내용은 노드가 n 개있는 완전한 트리 (리프 노드를 제외한 모든 노드에 두 개의 자식이 있음)가없는 경우 경로가 1 + log n 노드 이상일 수 없음을 읽었습니다. 내가 잘못 않은 곳 .... 이진 검색 트리 작업 시간 분석
the first level of bst has only one node(i.e. the root)-->2^0
the second level have 2 nodes(the children of root)---->2^1
the third level has 2^3=8 nodes
.
.
the (x+1)th level has 2^x nodes
so the total number of nodes =n = 2^0 +2^1 +2^2 +...+2^x = 2^(x+1)-1
so, x=log(n+1)-1
now as it is a 'complete' tree...the longest path(which has most no of nodes)=x
and so the nodes experienced in this path is x+1= log(n+1)
는 그럼 어떻게 숫자 1 +가 올 N 로그 않았다 여기
내가했던 계산은 ... 당신이 나를 보여줄 수있다 ...?
경로 정의는 무엇입니까? 나무를 감독으로 보았습니까 (가장자리는 부모 노드에서 자식 노드로 만 이동 함) 또는 방향이 없습니다 (가장자리는 "양방향"으로 이동) 그래프입니까? – Philippe
@Philippe ... 그것은 무향 그래프입니다 – avinash
OK ... log (n + 1) - 1 경계는 _root_에서 모든 노드까지의 경로에 대한 최대 길이와 일치하는 것으로 보입니다. – Philippe