GATE CSE
First time here? Checkout the FAQ!
x
+4 votes
515 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 DS by Veteran (20.8k points)  
retagged by | 515 views

2 Answers

+13 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.9k 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) . 

 
   

 

Q. -> In an AVL tree sometimes search can succeed in first or second try. So, it should be O(logn) and not Θ(logn) rt?

Ans. -> Yes, You are correct. Thanks for your careful observation.

Refer -> https://stackoverflow.com/questions/10376740/what-exactly-does-big-%D3%A8-notation-represent

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


Top Users Sep 2017
  1. Habibkhan

    7142 Points

  2. Warrior

    2640 Points

  3. Arjun

    2480 Points

  4. rishu_darkshadow

    2466 Points

  5. A_i_$_h

    2214 Points

  6. nikunj

    1980 Points

  7. manu00x

    1846 Points

  8. makhdoom ghaya

    1770 Points

  9. Bikram

    1744 Points

  10. SiddharthMahapatra

    1718 Points


26,133 questions
33,705 answers
79,886 comments
31,105 users