Ticker

6/recent/ticker-posts

Data structure subjective question for competitive exam(4)

Q1.What is the maximum height of any AVL tree with 7 nodes.Assume that the height of a tree with a single node is 0.

N(h)=N(h-1)+N(h-2)+1 for n>2 where N(0)=1 and N(1)=2 so N(2)=N(1)+N(0)+1=2+1+1=4 height 2 is achieved with 4 nodes. N(3)=N(2)+N(1)+1=4+2+1=7 when node is 7 height is 4.



Q2.What is maximum number of nodes on level 5 of binary tree.

maximum number of nodes in a binary tree of depth k 2^k-1 where k>=1 2^5-1=2^4=16



Q3.In a binary tree the number of internal nodes of degree 1 is 5 and number of nodes of degree 2 is 10.The number of leaf nodes in the binary tree is.

number of vertices=n number of edges=n-1 so n-1=1*5+2*10 n-1=5+20 n=26 number of leaf nodes=26-5-10=11


Q4.A 3-arry tree is a tree in which every internal node has exactly 3 children.The number of leaf nodes in such a tree with 6 internal nodes will be.

=(2(n-1)+3) =2(6-1)+3=13


Q5.What is maximum number of nodes on depth 4 of binary tree.

=2^k-1 =2^3=8



Post a Comment

0 Comments