recategorized by
1,220 views

2 Answers

1 1 vote
5 nodes have max levels=5

n nodes have max level=n

 For binary tree max height = number of levels -1

so O(n) is correct.
0 0 votes
The height of the binary tree in the worst case is O(N). We can calculate the the function g(x) in constant time C , therefore total cost is O(cN) or O(N)  in the worst case. This is O(logN) in the best case.
Position:
Show:

Related questions

1 1 vote
2 2 answers
2.0k
2.0k views
CHïntän ÞäTël asked Dec 10, 2018
1,955 views
four vertices {A,B,C,D} is given which has only vertex D as a leaf total number of binary tree are possible when every binary tree has four node!
0 0 votes
0 0 answers
735
735 views
sunaina rawat asked Nov 7, 2017
735 views
Consider programint foo(struct node *tree){if(tree==0)return 0;int lh=ht(tree->left);int rh=ht(tree->right);int ld=foo(tree->left);int rd=foo(tree->right);return max(lh+r...
0 0 votes
1 1 answer
630
630 views
0 0 votes
1 1 answer
1.1k
1.1k views