MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Balance factor is defined as the
A
Difference between Left sub tree and Right sub tree
B
Difference between the height of Left sub tree and the height of Right sub tree
C
Difference between Right sub tree and Left sub tree
D
Difference between the height of Right sub tree and the height of Left sub tree
Explanation: 

Detailed explanation-1: -More formally, we define the balance factor for a node as the difference between the height of the left subtree and the height of the right subtree. Using the definition for balance factor given above we say that a subtree is left-heavy if the balance factor is greater than zero.

Detailed explanation-2: -DEFINITION: The balance factor of a binary tree is the difference in heights of its two subtrees (hR-hL). The balance factor (bf) of a height balanced binary tree may take on one of the values-1, 0, +1.

Detailed explanation-3: -If the balance factor of a node is 0, then it means that the height of the left sub-tree is equal to the height of its right sub-tree. If the balance factor of a node is-1, then it means that the left sub-tree of the tree is one level lower than that of the right sub-tree. Such a tree is called Right-heavy tree.

Detailed explanation-4: -That property states that the difference between the height of the left sub-tree and the right sub-tree of any node can’t be more than 1. This property gives a Balance Factor which whose value should be from -1, 0, 1 in the case of AVL tree.

Detailed explanation-5: -Height balanced binary trees can be denoted by HB(k), where k is the difference between heights of left and right subtrees. ‘k’ is known as the balance factor. If for a tree, the balance factor (k) is equal to zero, then that tree is known as a fully balanced binary tree. It can be denoted as HB(0).

There is 1 question to complete.