GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
389 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 (19.2k points)   | 389 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 May 2017
  1. akash.dinkar12

    3338 Points

  2. pawan kumarln

    2066 Points

  3. Bikram

    1922 Points

  4. sh!va

    1672 Points

  5. Arjun

    1614 Points

  6. Devshree Dubey

    1272 Points

  7. Debashish Deka

    1174 Points

  8. Angkit

    1056 Points

  9. LeenSharma

    1018 Points

  10. Arunav Khare

    758 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 May 22 - 28
  1. Bikram

    1008 Points

  2. pawan kumarln

    692 Points

  3. Arnab Bhadra

    632 Points

  4. Arjun

    342 Points

  5. bharti

    328 Points


22,888 questions
29,193 answers
65,292 comments
27,691 users