Exponential Search Algorithm
Exponential Search Algorithm
i←1
While i < length(arr) and arr[i] <= target:
i←i*2
Return -1
The doubling step (i *= 2) continues until it either finds a larger value or goes out of
bounds.
After locating the interval, the binary search efficiently pinpoints the target element.
Implementation in Python
def binary_search(arr, left, right, target):
while left <= right:
mid = left + (right - left) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1
# Example
arr = [1, 2, 4, 7, 9, 14, 20, 23, 30, 40]
target = 14
index = exponential_search(arr, target)
print("Target found at index:", index)
You can implement this in other languages like C++, Java, or JavaScript as well — let me
know if you'd like those versions.
Time Complexity Analysis
Case Time Complexity
Conclusion
Exponential Look is an exquisite and proficient looking calculation outlined for sorted
information, particularly in scenarios where the estimate of the information isn't settled or
obscure. It leverages the control of exponential development to rapidly limit down the region of
interest and after that employments parallel look for exact component area. Whereas it may not
continuously outflank parallel look in each case, it gives critical execution benefits in particular
utilize cases, such as when the target is close the begin or when managing with unbounded
datasets. Its half breed nature makes it a awesome choice in frameworks requiring both speed
and versatility.
References
1. Bentley, J. L., & Yao, A. C. (1976). An Almost Optimal Algorithm for Unbounded
Searching.
2. Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to
Algorithms (MIT Press, 3rd Edition).
3. https://www.geeksforgeeks.org/exponential-search/
4. https://visualgo.net/en/search
5. https://www.programiz.com/dsa/exponential-search
6. https://www.scaler.com/topics/exponential-search/
7. https://www.tutorialspoint.com/exponential-search-in-data-structure
8. https://www.cs.princeton.edu/courses/archive/spring03/cs226/lectures/search/srch.pdf