This is an example of a binary search algorithm. For more information on binary searches read https://www.geeksforgeeks.org/binary-search/. A binary search is O(log N), this is superior to a linear search which is O(n). If you are unfamiliar with big O notation read https://www.geeksforgeeks.org/analysis-of-algorithms-set-3asymptotic-notations/.