UGC-NET Dec 2012 · Trees

MCQ · 2 marks · Problem PROG-DSTR-0008

The worst case time complexity of AVL is tree is better in comparison to binary search tree for
  1. A
    Search and Insert Operations
  2. B
    Search and Delete Operations
  3. C
    Insert and Delete Operations
  4. D
    Search, Insert and Delete Operations

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionAn AVL tree keeps the heights of the two subtrees of every node within 1, so its height is always \(O(\lg n)\); rebalancing after insert or delete costs only \(O(\lg n)\) rotations. An ordinary BST can degenerate into a chain (e.g. keys inserted in sorted order), with height \(n-1\).\[\text{Worst case}\quad \text{AVL: }O(\lg n),\qquad \text{BST: }O(n)\]for search, insert and delete alike, so AVL is better for all three.Answer: D

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com