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.

```
/**
* Created by gazollajunior on 05/04/16.
*/
fun <T:Comparable<T>>linearSearch(list:List<T>, key:T):Int?{
for ((index, value) in list.withIndex()) {
if (value == key) return index
}
return null
}
fun main(args: Array<String>) {
println("\nOrdered list:")
val ordered = listOf<String>("Adam", "Clark", "John", "Tim", "Zack")
println(ordered)
val name = "John"
val position = linearSearch(ordered, name)
println("\n${name} is in the position ${position} in the ordered List.")
}
```