. If 2,000 elements are inserted into a binary search tree using the traditional, naïve algorithm what is the height of the tree (give the actual number, not the order) in:
The worst case
The best case
(Please explain not just answer)
The maximum number of edges from the root to any leaf node provides the height of the tree.
Total number of elements or nodes = 2000
Worst Case:
Height of the tree = n - 1 = 2000 - 1 = 1999
Explanation:
If the tree structure is a left-skewed binary tree. In the left-skewed binary tree, each and every node has one child only and this child is the left child. The height of a left-skewed binary tree is maximum.
Best Case:
Height of the tree = log2(n) = Floor (log2(2000)) = Floor (l0.97) = 10
Explanation:
If each and every node in a binary tree has two children starting from the root node to the leaf node. This tree is a full binary tree or a complete binary tree. It has a minimum height.
. If 2,000 elements are inserted into a binary search tree using the traditional, naïve algorithm...