# AVL Tree | Data Structure MCQs

1.

What maximum difference in heights between the leafs of a AVL tree is possible?

A.) log(n) where n is the number of nodes
B.) n where n is the number of nodes
C.) 0 or 1
D.) atmost 1

At every level we can form a tree with difference in height between subtrees to be atmost 1 and so there can be log(n) such levels since height of AVL tree is log(n).

2.

Why we need to a binary tree which is height balanced?

A.) to avoid formation of skew trees
B.) to save memory
C.) to attain faster memory access
D.) to simplify storing

In real world dealing with random values is often not possible, the probability that u are dealing with non random values(like sequential) leads to mostly skew trees, which leads to worst case. hence we make height balance by rotations.

3.

What is an AVL tree?

A.) a tree which is balanced and is a height balanced tree
B.) a tree which is unbalanced and is a height balanced tree
C.) a tree with three children
D.) a tree with atmost 3 children

It is a self balancing tree with height difference atmost 1.

4.

What is the maximum height of an AVL tree with p nodes?

A.) p
B.) log(p)
C.) log(p)/2
D.) p⁄2

Consider height of tree to be ‘he’, then number of nodes which totals to p can be written in terms of height as N(he)=N(he-1)+1+N(he-2). since N(he) which is p can be written in terms of height as the beside recurrence relation which on solving gives N(he)= O(logp) as worst case height.

5.

Why to prefer red-black trees over AVL trees?

A.) Because red-black is more rigidly balanced
B.) AVL tree store balance factor in every node which costs space
C.) AVL tree fails at scale
D.) Red black is more efficient