arrow
arrow
arrow
What is the height of an AVL tree with 12 nodes, assuming the degree of the root node is 0?
Question



What is the height of an AVL tree with 12 nodes, assuming the degree of the root node is 0?

A.

3

B.

4

C.

5

D.

6

E.

None of the above

Correct option is B

The height of an AVL tree is determined by the number of levels in the tree, where the height is defined as the longest path from the root to any leaf. AVL trees are balanced binary search trees, meaning the difference in heights of the left and right subtrees is at most 1.
For 12 nodes, the height h of an AVL tree can be calculated using the formula for the minimum number of nodes in an AVL tree:
N(h)=N(h−1)+N(h−2)+1
Where:
· N(h−1) is the number of nodes in the left subtree.
· N(h−2) is the number of nodes in the right subtree.
The height h is the smallest value for which N(h)≥12. Using the minimum nodes for each height:
· Height 1: N(1)=1
· Height 2: N(2)=2
· Height 3: N(3)=4
· Height 4: N(4)=7
· Height 5: N(5)=12
Thus, the height of the AVL tree is 4 because it satisfies the N(h)=12.
Important Key Points:
1. AVL Tree maintains balance by ensuring the height difference between left and right subtrees of any node is at most 1.
2. The height of an AVL tree with n nodes grows logarithmically, i.e.,h=O(logn).
3. The AVL tree is named after its inventors Adelson-Velsky and Landis.
4. Rotation operations (single or double) are used to maintain the height balance property of AVL trees during insertion or deletion.
5. The formula N(h)=N(h−1)+N(h−2)+1 is similar to the Fibonacci sequence for balancing nodes.
Knowledge Booster:
· Binary Search Tree (BST): AVL trees are a subset of BSTs but are balanced, unlike a regular BST, which can become skewed.
· Height-Balanced Property: Ensures efficient operations like search, insert, and delete, all in O(logn).
· Tree Rotations: Includes left rotation, right rotation, left-right rotation, and right-left rotation to maintain balance.
· Maximum Height of a Binary Tree: Without balancing, the height could grow to n−1, making operations inefficient (O(n)).

Free Tests

Free
Must Attempt
Video Solutions

RBI Assistant Pre 2026 Full Mock Test -01

languageIcon English
  • pdpQsnIcon100 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt
Video Solutions

RBI Asst Prelims 2026 : Reasoning Section Test 01

languageIcon English
  • pdpQsnIcon35 Questions
  • pdpsheetsIcon35 Marks
  • timerIcon20 Mins
languageIcon English
Free
Must Attempt
Video Solutions

RBI Office Attendant 2026 Full Mock Test - 01

languageIcon English
  • pdpQsnIcon120 Questions
  • pdpsheetsIcon120 Marks
  • timerIcon90 Mins
languageIcon English
test-prime-package

Access ‘IBPS SO IT Officer’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
354k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow