• edited by
19,766 views
45 45 votes

Which of the following is TRUE?

  1. The cost of searching an AVL tree is $\Theta (\log n)$ but that of a binary search tree is $O(n)$
  2. The cost of searching an AVL tree is $\Theta (\log n)$ but that of a complete binary tree is $\Theta (n \log n)$
  3. The cost of searching a binary search tree is $O (\log n )$ but that of an AVL tree is $\Theta(n)$
  4. The cost of searching an AVL tree is $\Theta (n \log n)$ but that of a binary search tree is $O(n)$

4 Answers

Best answer
67 67 votes

A) is true as AVL tree is a balanced search tree that has time complexity of searching $\Theta ( \log n)$, but in binary search tree, we can have a completely left/right skewed tree, in which search is $O(n)$.

• edited by
0 0 votes
AVL trees guarantee height Θ(log⁡n)\Theta(\log n)Θ(logn), so search is Θ(log⁡n)\Theta(\log n)Θ(logn). A BST can be skewed with height Θ(n)\Theta(n)Θ(n), so worst-case search is O(n)O(n)O(n).
0 0 votes

(A) The cost of searching in AVL Tree is O(log n) because the height of AVL Tree is ⌈log n⌉ and The cost of searching in Binary Search Tree is O(n) because in worst case BST can be left/right Skewed , So we have to traverse all nodes for searching
So, Option(A) is correct

For Complete Binary Tree cost of serching is O(n) there is no ordering. So, for searching an element we have to traverse all nodes

Answer:
Position:
Show:

Related questions

46 46 votes
3 answers 3 answers
11.2k
11.2k views
Ishrat Jahan asked Oct 29, 2014
11,172 views
A Binary Search Tree (BST) stores values in the range $37$ to $573$. Consider the following sequence of keys.$81, 537, 102, 439, 285, 376, 305$$52, 97, 121, 195, 242, 381...
39 39 votes
4 answers 4 answers
19.3k
19.3k views
Ishrat Jahan asked Oct 29, 2014
19,290 views
How many distinct BSTs can be constructed with $3$ distinct keys?$4$$5$$6$$9$
78 78 votes
4 answers 4 answers
24.3k
24.3k views
Ishrat Jahan asked Oct 29, 2014
24,311 views
A Binary Search Tree (BST) stores values in the range $37$ to $573$. Consider the following sequence of keys.$81, 537, 102, 439, 285, 376, 305$$52, 97, 121, 195, 242, 381...
6 6 votes
1 1 answer
225
225 views
GO Classes asked Jul 23
225 views
For the following three trees, choose the correct classification.Tree (a):Tree (b):Tree (c):Which option is correct?All three are valid AVL trees. Tree (a) is not a valid...