answersLogoWhite

0


Best Answer

For the height `h' of a binary tree, for which no further attributes are given than the number `n' of nodes, holds:

ceil( ld n) <= h <= n

Where `ld' is the binary logarithm and `ceil' is rounding up to the next integer.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Maximum height of Binary Search Tree of nodes is n-1

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

n(n-1)/2

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

n

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the height of a binary tree with n nodes in the worst case?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the height of binary search tree in worst case?

In the worst case a binary search tree is linear and has a height equal to the number of nodes. so h=O(h).


What is the height of a complete binary tree of height h have?

Minimum is h nodes (Maximum is 2h+1 - 1 nodes, if tree consisting of only one node is considered to have height of 0. if you consider a tree with one node to be a height of one, then the minimum nodes is (2^(h-1)) 1 nodes. Minimum number of nodes in a binary tree of height is 2h+1. For example, if the height of the binary tree is 3, minimum number of nodes is 2*3+1=7.


What is the worst case and best case for interpolation search?

binary search


What is Efficiency of Binary Search tree operations?

If it is an unbalanced binary tree, O( ln( n ) / ln( 2 ) ) is best-case. Worst case is O( n ). If it is balanced, worst case is O( ln( n ) / ln( 2 ) ).


What is the worst case and best case for binary search?

The best case for a binary search is finding the target item on the first look into the data structure, so O(1). The worst case for a binary search is searching for an item which is not in the data. In this case, each time the algorithm did not find the target, it would eliminate half the list to search through, so O(log n).


What is a degenerate binary search tree?

A degenerate binary tree is one where most or all of the nodes contain only one sub node. It is unbalanced and, in the worst case, performance degrades to that of a linked list. If your add node function does not handle rebalancing, then you can easily construct a degenerate tree by feeding it data that is already sorted.


What is best and average case of binary search?

Merge sort is O(n log n) for both best case and average case scenarios.


What is recursive algorithm to find the height of a binary search tree with n numbers of nodes?

Really the best way to traverse any binary tree is recursion. In this case we are going to be some node defined as having 3 values, a pointer to a left node, a pointer to a right node, and a value. then in psudocode we can do it as: int height(node n, int depth){ int leftDepth; int rightDepth; if(n.left != NULL) leftDepth = height(n.left, depth+1) else leftDepth = depth; if(n.right != NULL) rightDepth = height(n.right, depth+1) else rightDepth = depth; if(leftDepth &gt; rightDepth) return leftDepth; return rightDepth; } Essentially what you are doing is calling the algorithm on both the left and right nodes which in turn will call it on their left and right nodes, down to where all the nodes are null. Then what is returned is the greater depth of the two; because it will traverse before returning a depth, and only traverses if there is a deeper node, it will return the depth of the deepest node, or the height of the binary tree.


How binary tree is represented as doubly link list?

In this representation, each node contains two pointers, one pointing to its parent (null in the case of root node) and the other pointing to its child node (null in the case of leaf nodes).


What is average case complexity of binary search?

Average case complexity for Binary search O(log N). (Big O log n)Habibur Rahman (https://www.facebook.com/mmhabib89)BUBT University Bangladeshhttp://www.bubt.edu.bd/


Is it worse case or worst case?

worst case- often hyphenated- the Oil disaster was a Worst-Case scenario in the Gulf area!


What is the time complexity for searching an element in an array?

If the array is unsorted, the complexity is O(n) for the worst case. Otherwise O(log n) using binary search.