May 2017
Intermediate to advanced
340 pages
8h 16m
English
In binary search, we are searching the whole list for a given key. Exponential search improves binary search by deciding the lower and upper bound of the search so that we do not end up searching the whole list. It improves the number of comparisons we need to find an element. The search is done in the following two steps:
Let's now implement the exponential search using our recursive binarySearch function:
function exponentialSearch(array $arr, int $key): int { $size = count($arr); ...Read now
Unlock full access