Which of the following is AVL Tree?
A
100
/ \
50 200
/ \
10 300
B
100
/ \
50 200
/ / \
10 150 300
/
5
C
100
/ \
50 200
/ \ / \
10 60 150 300
/ \ \
5 180 400
(A) Only A
(B) A and C
(C) A, B and C
(D) Only B
Answer: (B)
Explanation: A Binary Search Tree is AVL if balance factor of every node is either -1 or 0 or 1. Balance factor of a node X is [(height of X->left) – (height of X->right)].
In Tree B, the node with value 50 has balance factor 2. That is why B is not an AVL tree.
Quiz of this Question
Recommended Posts:
- Data Structures | Balanced Binary Search Trees | Question 2
- Data Structures | Balanced Binary Search Trees | Question 2
- Data Structures | Balanced Binary Search Trees | Question 10
- Data Structures | Balanced Binary Search Trees | Question 5
- Data Structures | Balanced Binary Search Trees | Question 13
- Data Structures | Balanced Binary Search Trees | Question 7
- Data Structures | Balanced Binary Search Trees | Question 13
- Data Structures | Balanced Binary Search Trees | Question 9
- Data Structures | Balanced Binary Search Trees | Question 13
- Data Structures | Balanced Binary Search Trees | Question 11
- Data Structures | Balanced Binary Search Trees | Question 12
- Data Structures | Balanced Binary Search Trees | Question 13
- Data Structures | Binary Search Trees | Question 1
- Data Structures | Binary Search Trees | Question 2
- Data Structures | Binary Search Trees | Question 3
- Data Structures | Binary Search Trees | Question 4
- Data Structures | Binary Search Trees | Question 5
- Data Structures | Binary Search Trees | Question 6
- Data Structures | Binary Search Trees | Question 7
- Data Structures | Binary Search Trees | Question 8

