What is the worst case time complexity of inserting n2 elements into an AVL-tree with n elements initially?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2020 · Q6
Time
Select one answerSingle correct
Solution
Official answer: C) (n2 log n)
Asymptotic AnalysisAn AVL tree is a self-balancing binary search tree. For an AVL tree containing elements, the height is , and the worst-case time to insert one element (including necessary rotations) is .
When inserting elements into an AVL tree initially containing elements:
For the -th insertion (), the tree contains elements, taking time.
The total time complexity is:
Bounding the sum:
Hence, the overall worst-case time complexity is , which corresponds to option (C).
Try the question first, then check your work.
Examiner trap
Recall that inserting an element into an AVL tree with nodes takes time in the worst case. Sum this insertion time over elements.
This Asymptotic Analysis previous year question is Q6 of the GATE CSE 2020 paper. Find more GATE CSE PYQs on Asymptotic Analysis in Algorithms, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Asymptotic Analysis PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Asymptotic Analysis has 31 GATE CSE PYQs across 19 papers from 2011 to 2026. 15 of them are 1-mark MCQs like this one, and GATE CSE 2020 has 2.
How GATE tests Asymptotic AnalysisIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.