Optimize a search algorithm to run in O(n) time complexity, ensuring you minimize the number of passes over the dataset.