What is the minimum number of nodes in an AVL tree of height
What is the minimum number of nodes in an AVL tree of height 8?
Let N(h) be the minimum number of nodes in an AVL tree of height h.
Solution
Given the height of the AVL tree is 8.
Let N(h) be the minimum number of nodes in AVL tree.
The formula to find minimum number of trees in an AVL tree is
N(h) = N(h-1)+N(h-2)+1
Here N(h) is a recursive function.For a recursive function N(1)=0 N(2) =1
Here height h = 8
So N(8) = N(8-1)+N(8-2)+1
N(8)= N(7)+N(6)+1
N(8) = [N(7-1)+N(7-2)+1]+ [N(6-1)+N(6-2)+1]+ 1
N(8)= [N(6)+N(5)+1]+ [N(5)+N(4)+1]+1
N(8)= N(6)+2*N(5)+N(4)+3
N(8)= [N(6-1)+N(6-2)+1]+ 2*[N(5-1)+N(5-2)+1]+[N(4-1)+N(4-2)+1]+3
N(8)= [N(5)+N(4)+1]+ 2*[N(4)+N(3)+1]+[N(3)+N(2)+1]+3
N(8)= N(5)+ 3*[N(4)+N(3)]+N(2)+7
N(8)= [N(5-1)+N(5-2)+1]+3*{ [N(4-1)+N(4-2)+1]+[N(3-1)+N(3-2)+1] }+7
N(8)= N(4)+N(3)+1+3*{ N(3)+N(2)+1+N(2)+N(1)+1}+7
N(8)= N(4)+N(3)+3*{ N(3)+N(2)+N(2)+N(1)}+14
N(8)= [N(4-1)+N(4-2)+1]+4*[N(3-1)+N(3-2)+1]+6*N(2)+3*N(1)+14
N(8)= N(3)+N(2)+1+4*[N(2)+N(1)+1]+6*N(2)+3*N(1)+14
N(8)= N(3-1)+N(3-2)+1+11*N(2)+7*N(1)+19
N(8)= N(2)+N(1)+11*N(2)+7*N(1)+20
N(8)= 12*N(2)+8*N(1)+20
N(8)= 12*1+8*0+20 Since N(1)=0 and N(2)=1
N(8)= 12+0+20
N(8)= 32
The minimum number of nodes in an AVL ttree of height 8 is 32.
