We have the best collection of AVL Tree MCQs and answer with FREE PDF. These AVL Tree MCQs will help you to prepare for any competitive exams like: BCA, MCA, GATE, GRE, IES, PSC, UGC NET, DOEACC Exams at all levels – you just have to practice regularly.

## AVL Tree MCQs

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

a) p

b) log(p)

c) log(p)/2

d) p⁄2

**Answer: **log(p)

**2. Consider the below left-left rotation pseudo code where the node contains value pointers to left, right child nodes and a height value and Height() function returns height value stored at a particular node.**

```
avltree leftrotation(avltreenode z):
avltreenode w =x-left
x-left=w-right
w-right=x
x-height=max(Height(x-left),Height(x-right))+1
w-height=max(missing)+1
return w
```

What is missing?

a) Height(w-left), x-height

b) Height(w-right), x-height

c) Height(w-left), x

d) Height(w-left)

**Answer: **Height(w-left), x-height

**3. Consider the pseudo code:**

```
int avl(binarysearchtree root):
if(not root)
return 0
left_tree_height = avl(left_of_root)
if(left_tree_height== -1)
return left_tree_height
right_tree_height= avl(right_of_root)
if(right_tree_height==-1)
return right_tree_height
```

Does the above code can check if a binary search tree is an AVL tree?

a) yes

b) no

**Answer: **yes

**4. 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

**Answer: **a tree which is balanced and is a height balanced tree

**5. 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

**Answer: **to avoid formation of skew trees

**6. 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

**Answer: **AVL tree store balance factor in every node which costs space

**7. To restore the AVL property after inserting a element, we start at the insertion point and move towards root of that tree. is this statement true?**

a) true

b) false

**Answer: **true

**8. Given an empty AVL tree, how would you construct AVL tree when a set of numbers are given without performing any rotations?**

a) just build the tree with the given input

b) find the median of the set of elements given, make it as root and construct the tree

c) use trial and error

d) use dynamic programming to build the tree

**Answer: **find the median of the set of elements given, make it as root and construct the tree

**9. 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

**Answer: **log(n) where n is the number of nodes