We can improve the worst case of sequential search in a probabilistic sense, if the element belongs to the set (successful search) and we have all the elements in advance (off-line case). Consider the following randomized algorithm. We flip a coin. If it is a head, we search the set from to , otherwise, from to . The worst case for each possibility is comparisons. However, we have two algorithms and not only one. Suppose that the element we are looking for is in position and that the coin is fair (that is, the probability of head or tail is the same). So, the number of comparisons to find the element is , if it is a head, or if it is a tail. So, averaging over both algorithms (note that we are not averaging over all possible inputs), the expected worst case is
which is independent of where the element is! This is better than . In other words, an adversary would have to place the element in the middle position because he/she does not know which algorithm will be used.