COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
What is the biggest disadvantage of a binary search?
|
It is slow
|
|
It can only be used if the data is sorted into an order
|
|
It takes the data and keeps dividing it in half until it finds the item it is looking for
|
|
None of the above
|
Explanation:
Detailed explanation-1: -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. Although an array can be sorted before running the Binary Search algorithm, the sorting algorithm will increase the overall time complexity.
Detailed explanation-2: -The biggest problem with a binary search is that you can only use this if the data is sorted into an order.
Detailed explanation-3: -The key drawback is that a balanced binary search tree needs to be implemented at all times. Otherwise, it’s possible that the cost of operations won’t be logarithmic and will instead result in a linear array search.
There is 1 question to complete.