recategorized by
658 views
4 votes
4 votes

Which of the following statements is/are TRUE?

  1. Suppose there are $n$ nodes are present in a binary search tree. The height of any binary search tree is $\theta (\log n)$
  2. $\theta (\log n)$ rotations are required to insert into AVL tree with n nodes.

 

  1. Only I
  2. Only II
  3. Both I and II
  4. Neither I nor II
recategorized by

1 Answer

2 votes
2 votes
I. False. In the best case, the height of a BST is $O(\log n)$ if it is balanced. In the worst case, however, it can be $\theta(n)$.
II. False. There were two ways you can show this.
1. There are cases where inserting into an AVL tree requires no rotation $\theta (\log n)$ rotations implies $\Omega (\log n)$ rotations. Since we have insertions that require no rotations, this means that inserting into an AVL tree does not require $\Omega (\log n)$ rotations and thus it does not require $\theta ( \log n)$ rotations.
2. Inserting into an AVL tree may look at $O( \log n)$ nodes, but it only needs to perform at most $2$ rotations to fix the imbalance. Thus inserting into an AVL tree requires $O(1)$ rotations, which is not $\theta (\log n)$.
Answer:

Related questions

1 votes
1 votes
0 answers
4
Applied Course asked Jan 16, 2019
1,014 views
What is the maximum number of activation records inserted into stack while converting following infix expression to postfix expression is Infix expression: $\text{7+5*3^2...