How does linear search perform on sorted versus unsorted arrays?

  • Better on sorted arrays
  • Better on unsorted arrays
  • Equally efficient on both
  • Performs differently based on array length
Linear search performs better on sorted arrays. This is because, in a sorted array, once a value greater than the target is encountered, the search can stop, resulting in early termination. On the other hand, in an unsorted array, the search continues until the target is found or the entire array is traversed.
Add your answer
Loading...

Leave a comment

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