It seems like you are using binary search where you traverse array from start to the end. In binary search the best , worst and average time complexities are: Best : O(1) , you get your element in the first indext Average and worst : O(logn) , The target element is at the first or last index of the array.