If each component is equally likely to be searched, then linear search has an average case of n+1/2 comparisons, but the average case can be affected if the search probabilities for each component vary. In computer science, a linear search or sequential search is a method for finding an component within a list.

A linear search sequentially checks each component of the list until it finds an component that matches the target value. If the algorithm reaches the end of the list, the search terminates unsuccessfully.

```
=begin
Looks through array for a value in O(n) time.
Array does not need to be sorted.
=end
def linear_search(array, key)
array.each_with_index do |current, index|
return index if current == key
end
return nil
end
puts "Enter a space-separated list:"
arr = gets.chomp.split(' ').map(&:to_i)
puts "Enter a value to be searched:"
key = gets.chomp.to_i
puts linear_search(arr, key) != nil ?
"Found at index #{linear_search(arr, key)}" :
"Not found"
```