MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
If the tree is balanced, the performance will be improved:from O(n) to O(log n) for finding the minimum value
A
YES
B
NO
C
Either A or B
D
None of the above
Explanation: 

Detailed explanation-1: -Balance factor of a node in an AVL tree is the difference between the height of the left subtree and that of the right subtree of that node. The self balancing property of an avl tree is maintained by the balance factor. The value of balance factor should always be-1, 0 or +1.

Detailed explanation-2: -Balanced Binary trees are computationally efficient to perform operations on. A balanced binary tree will follow the following conditions: The absolute difference of heights of left and right subtrees at any node is less than 1. For each node, its left subtree is a balanced binary tree.

Detailed explanation-3: -The Time complexity of a Balanced Binary Searched Tree is logN, as stated in Wikipedia, because as it traverses the tree, it either goes left or right eliminating half of the whole Tree. For an unbalanced Binary search tree, the time complexity is O(n), it’s basically similar to a linear search.

Detailed explanation-4: -Approach: Just traverse the node from root to left recursively until left is NULL. The node whose left is NULL is the node with the minimum value.

There is 1 question to complete.