0% found this document useful (0 votes)
5 views7 pages

Exponential Search Algorithm

The Exponential Search Algorithm is designed for sorted arrays, particularly effective for large datasets where the size is unknown. It works by exponentially increasing the search index until it finds a range containing the target, followed by a binary search within that range. This algorithm, introduced by Jon Bentley and Andrew Chi-Chih Yao in 1976, offers significant performance benefits in specific scenarios, such as when the target is near the beginning of the dataset.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

Exponential Search Algorithm

The Exponential Search Algorithm is designed for sorted arrays, particularly effective for large datasets where the size is unknown. It works by exponentially increasing the search index until it finds a range containing the target, followed by a binary search within that range. This algorithm, introduced by Jon Bentley and Andrew Chi-Chih Yao in 1976, offers significant performance benefits in specific scenarios, such as when the target is near the beginning of the dataset.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Exponential Search Algorithm – Detailed Report

Explanation: How It Works, Its Principle, and History


Overview:
Exponential Look may be a look calculation utilized particularly for sorted clusters or records.
It is especially compelling when managing with huge datasets where the estimate might not be
completely known or when the component to be looked is found closer to the starting of the
cluster.
Working Mechanism:
The look starts by checking the primary component. In case it does not coordinate the target, the
calculation starts an exponential increment within the look file (i.e., list = 1, 2, 4, 8, 16, ...) until
it either:
 Comes to an file past the estimate of the cluster, or
 Experiences an component more noteworthy than the target.
Once a substantial run is distinguished (from file i/2 to min (i, length - 1)), a parallel look is
performed inside that restricted run to discover the target component.
Underlying Principle:
 The rule of this calculation lies within the effectiveness of diminishing the look space
exponentially some time recently applying parallel look.
 The exponential development step minimizes the number of comparisons fundamental to
find the surmised position of the target.
Comparison to Binary Search:
Whereas Double Look continuously starts by dividing the full cluster, Exponential Look finds a
more exact locale to apply parallel look, particularly valuable when the dataset is expansive or
mostly obscure in measure.
Historical Background:
 The calculation was presented by Jon Bentley and Andrew Chi-Chih Yao in their 1976
paper titled "An Nearly Ideal Calculation for Unbounded Searching".
 It was initially planned to bargain with scenarios where the dataset is unbounded, such as
unbounded clusters, or when as it were a fractional cluster is available in gushing
applications.
 Exponential Look got to be important in hypothetical computer science and real-world
applications such as looking in databases or memory with fragmented structures.

Two Detailed Examples


Example 1: Basic Search in a Small Sorted Array
 Array: [2, 4, 8, 10, 14, 18, 22, 26, 30, 34]
 Target: 22
Steps:
1. Check arr[0] = 2 → not a match.
2. Start exponential range check:
o i = 1 → arr[1] = 4
o i = 2 → arr[2] = 8
o i = 4 → arr[4] = 14
o i = 8 → arr[8] = 30 > 22 → stop.
3. Binary search from index 4 to 8:
o Mid = 6 → arr[6] = 22 → match found at index 6
Example 2: Large Array, Target Near Beginning
 Array: [1, 3, 5, 7, 9, 11, 13, 15, ..., 99] (sorted up to 99)
 Target: 5
Steps:
1. Check arr[0] = 1 → not a match.
2. i = 1 → arr[1] = 3
3. i = 2 → arr[2] = 5 → match found directly, no binary search needed
This highlights the best-case efficiency of exponential search when the element is near the
start.
Algorithm and Pseudocode
Function ExponentialSearch(arr, target):
If arr[0] == target:
return 0

i←1
While i < length(arr) and arr[i] <= target:
i←i*2

Return BinarySearch(arr, i / 2, min(i, length(arr) - 1), target)

Function BinarySearch(arr, left, right, target):


While left ≤ right:
mid ← left + (right - left) / 2
If arr[mid] == target:
return mid
Else If arr[mid] < target:
left ← mid + 1
Else:
right ← mid - 1

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

def exponential_search(arr, target):


if arr[0] == target:
return 0
i=1
while i < len(arr) and arr[i] <= target:
i *= 2
return binary_search(arr, i // 2, min(i, len(arr) - 1), target)

# 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

Best Case O(1)

Average O(log i) + O(log i) = O(log i)

Worst Case O(log n)


Where:
 i is the index where the exponential search stops.
 n is the length of the array.
Explanation:
 The exponential search phase takes O(log i) comparisons.
 Binary search afterward also takes O(log i).
 Therefore, total time is O(log i), which can be considered O(log n) in the worst case.

Applications of Exponential Search


 Looking in Unbounded Clusters: Particularly valuable in cases where the length of the
cluster is obscure (e.g., gushing information).
 Productive for Expansive Sorted Records: Performs superior than parallel look when
the component is found near to the starting.
 Look in Records or Organize Streams: Valuable in frameworks where irregular get to
is expensive.
 Look in Connected Information Structures: In case combined with hop pointers,
exponential look can be valuable in trees or connected records.
 Memory-Constrained Frameworks: Can minimize memory utilization by narrowing
the look space early.

Features, Advantages, and Disadvantages


Features:
 Combines exponential and twofold look procedures.
 Works as it were with sorted datasets.
 Decreases pointless comparisons in huge datasets.
Advantages:
 Proficient in terms of time when the target is close the begin.
 Diminishes the double look space, sparing on comparisons.
 Best suited for unbounded or unbounded clusters.
 Superior than parallel look in somewhat known clusters.
Disadvantages:
 As it were appropriate to sorted clusters.
 Overhead of exponential step in exceptionally little clusters.
 Requires arbitrary get to to components (less suited for immaculate connected records).
 May be less proficient than twofold look in a few adjusted datasets.

Online Demonstration Tools


 Visual go: Visual simulation of exponential and binary search with animations.
 GeeksforGeeks Live Editor: Includes interactive examples and code you can run.
 Program: Visual and code-based explanation of the algorithm.
 Algo Expert: (Paid) platform for algorithm demos and problem-solving practice.

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

You might also like