Logarithm, Algorithms, Java, Data Structures, Programming.
worst-case scenario. A better way is to use a binary search algorithm, which has a logarithmic time complexity of O(log n). In a binary search, you would start in the middle of the list, if the middle element isn’t the one you’re looking for, you eliminate half of the list that doesn’t need to be