Imagine you have a large dataset of sorted integers and need to efficiently locate a specific value. Would binary search be an appropriate choice for this task? Justify your answer.

  • No, because binary search only works for textual data, not integers.
  • No, binary search is not suitable for sorted datasets.
  • Yes, because binary search has a time complexity of O(log n) and is efficient for sorted datasets.
  • Yes, but only if the dataset is small.
Binary search is appropriate for this task because of its time complexity of O(log n), making it efficient for large sorted datasets. The sorted nature allows for quick elimination of half the elements at each step. It is not restricted to textual data and is well-suited for numerical information as well.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *