GATE 2020 CS – Question 16
What is the worst case time complexity of inserting $n^2$ elements into an AVL-tree with $n$ elements initially?
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (C) $\Theta(n^2\log n)$
Explanation
Each insertion costs $O(\log(\text{size}))$, and the size stays between $n$ and $n^2+n$, so each insertion is $\Theta(\log n)$. Total is $\Theta(n^2\log n)$.