GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
302 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 (18.3k points)   | 302 views

2 Answers

+8 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.5k 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.2k points)  
Top Users Jan 2017
  1. Debashish Deka

    7172 Points

  2. Habibkhan

    4696 Points

  3. Vijay Thakur

    4308 Points

  4. sudsho

    4090 Points

  5. saurabh rai

    4024 Points

  6. Arjun

    3292 Points

  7. santhoshdevulapally

    3066 Points

  8. GateSet

    3016 Points

  9. Bikram

    3014 Points

  10. Sushant Gokhale

    2892 Points

Monthly Topper: Rs. 500 gift card

18,838 questions
23,808 answers
51,588 comments
20,148 users