Imagine you have a list of names sorted alphabetically, and you need to find a particular name. Would linear search or binary search be more suitable for this scenario? Justify your choice.

  • Binary search
  • Exponential search
  • Interpolation search
  • Linear search
In a scenario with a sorted list of names, binary search would be more suitable than linear search. Binary search has a time complexity of O(log n), making it more efficient for sorted data compared to the linear search with O(n) time complexity. Binary search consistently halves the search space, allowing for quicker identification of the target name.
Add your answer
Loading...

Leave a comment

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