MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Maximum number of comparisons required to search the leaf node of Binary search tree is
A
log n
B
n
C
n+1
D
n-1
Explanation: 

Detailed explanation-1: -In the worst case, you need 9 comparisons to reach the leaf node. You still need to have one more comparison against the leaf node to see if the value matches. So you need 10 comparisons. If it guarantees the key is part of the tree, you only need 9 comparisons.

Detailed explanation-2: -The maximum number of nodes at any level: In a binary tree, the maximum number of nodes gained by any level is equal to the power of 2 for that level. In a simpler words, the level is donated by n. Then, maximum nodes of that binary tree will be 2n.

Detailed explanation-3: -The maximum number of comparisons is logarithmic with respect to the number of items in the list. Therefore, the binary search is O(log n) .

Detailed explanation-4: -Full Binary Tree Theorems The number of internal nodes is (n – 1) / 2 . The number of leaves is (n + 1) / 2 . The total number of nodes is 2l – 1 .

Detailed explanation-5: -A tree has maximum nodes if all levels have maximum nodes. So the maximum number of nodes in a binary tree of height h is 1 + 2 + 4 + .. + 2h-1.

There is 1 question to complete.