In what scenarios is linear search preferable over binary search?

  • Linear search is never preferable
  • When the array is large and sorted
  • When the array is large but not sorted
  • When the array is small or not sorted
Linear search is preferable over binary search in scenarios where the array is small or not sorted. In such cases, the simplicity of linear search can be more efficient than the overhead involved in binary search, especially for small datasets or unsorted arrays where the linear search can terminate as soon as the element is found.
Add your answer
Loading...

Leave a comment

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