COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
3
|
|
4
|
|
5
|
|
6
|
Detailed explanation-1: -It would take only three iterations with the Binary Search algorithm. However, the main disadvantage of the Binary Search algorithm is that it requires a sorted array to discard half of the search space at each iteration.
Detailed explanation-2: -In a binary search algorithm, the array taken gets divided by half at every iteration. Again dividing by half in the third iteration will make the array’s length = (n/2)/2=n/(2^k).
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: -Explanation: Even though the first two elements are already sorted, bubble sort needs 4 iterations to sort the given array.