GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
351 views

Which of the following is TRUE?

  1. The cost of searching an AVL tree is θ (log n) but that of a binary search tree is O(n)
  2. The cost of searching an AVL tree is θ (log n) but that of a complete binary tree is θ (n log n)
  3. The cost of searching a binary search tree is O (log n ) but that of an AVL tree is θ(n)
  4. The cost of searching an AVL tree is θ (n log n) but that of a binary search tree is O(n)
asked in Algorithms by Veteran (19k points)   | 351 views

2 Answers

+10 votes
Best answer
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)$.
answered by Veteran (10.7k points)  
selected by
In an AVL tree sometimes search can succeed in first or second try. So, it should be $O(\log n)$ and not $\Theta(\log n)$ rt?

if we find the maximum height with minimum no of nodes then the height H = n/2 , without violating the property of the AVL tree . Then the cost of searching  in AVL tree could be O(n/2) . Not always necessary to be Log(n) . 

 
   

 

0 votes
option A is right
answered by Active (1.3k points)  


Top Users Mar 2017
  1. rude

    5118 Points

  2. sh!va

    3054 Points

  3. Rahul Jain25

    2920 Points

  4. Kapil

    2730 Points

  5. Debashish Deka

    2602 Points

  6. 2018

    1574 Points

  7. Vignesh Sekar

    1422 Points

  8. Akriti sood

    1382 Points

  9. Bikram

    1350 Points

  10. Sanjay Sharma

    1128 Points

Monthly Topper: Rs. 500 gift card

21,531 questions
26,861 answers
61,191 comments
23,206 users