What is the worst-case height of an AVL tree with n nodes?
- A O(n)
- B O(log n)
- C O(n log n)
- D O(n^2)
Explanation
Because an AVL tree stays balanced, its height grows logarithmically, so search, insertion and deletion all take O(log n) time.
What is the worst-case height of an AVL tree with n nodes?
Because an AVL tree stays balanced, its height grows logarithmically, so search, insertion and deletion all take O(log n) time.