Explain why binary search is more efficient than linear search for large datasets.

  • Binary search always finds the element in the first comparison
  • Binary search can only be used with small datasets
  • Binary search divides the search space in half at each step, reducing the time complexity to O(log n)
  • Linear search has a time complexity of O(n^2)
Binary search is more efficient for large datasets because it divides the search space in half at each step, resulting in a time complexity of O(log n), which is significantly faster than linear search (O(n)).
Add your answer
Loading...

Leave a comment

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