ArticleslgStudy

computer science

Exponential search

Exponential search is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Exponential search rather than just read about it. In short: In computer science, an exponential search (also called doubling search or galloping search or Struzik search) is an algorithm, created by Jon Bentley and Andrew Chi-Chih Yao in 1976, for searching sorted, unbounded/infinite lists. There are numerous ways to implement this, with the most common being to determine a range that the search key resides in and performing a binary search within that range.

Key takeaways

  • Exponential search belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Exponential search to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Exponential search from memory before moving on to harder problems.

Reference excerpt

In computer science, an exponential search (also called doubling search or galloping search or Struzik search) is an algorithm, created by Jon Bentley and Andrew Chi-Chih Yao in 1976, for searching sorted, unbounded/infinite lists. There are numerous ways to implement this, with the most common being to determine a range that the search key resides in and performing a binary search within that range. This takes O(log⁡i) time, where i is the position of the search key in the list, if the search key is in the list, or the position where the search key should be, if the search key is not in the list. Exponential search can also be used to search in bounded lists. Exponential search can even out-perform more traditional searches for bounded lists, such as binary search, when the element being searched for is near the beginning of the array. This is because exponential search will run in O(log⁡i) time, where i is the index of the element being searched for in the list, whereas binary search would run in O(log⁡n) time, where n is the number of elements in the list.

Algorithm Exponential search allows for searching through a sorted, unbounded list for a specified input value (the search "key"). The algorithm consists of two stages. The first stage determines a range in which the search key would reside if it were in the list. In the second stage, a binary search is performed on this range. In the first stage, assuming that the list is sorted in ascending order, the algorithm looks for the first exponent, j, where the value 2j is greater than the search key. This value, 2j becomes the upper bound for the binary search with the previous power of 2, 2j - 1, being the lower bound for the binary search.

In each step, the algorithm compares the search key value with the key value at the current search index. If the element at the current index is smaller than the search key, the algorithm repeats, skipping to the next search index by doubling it, calculating the next power of 2. If the element at the current index is larger than the search key, the algorithm now knows that the search key, if it is contained in the list at all, is located in the interval formed by the previous search index, 2j - 1, and the current search index, 2j. The binary search is then performed with the result of either a failure, if the search key is not in the list, or the position of the search key in the list.

Performance The first stage of the algorithm takes O(log⁡i) time, where i is the index where the search key would be in the list. This is because, in determining the upper bound for the binary search, the while loop is executed exactly ⌈log⁡(i)⌉ times. Since the list is sorted, after doubling the search index ⌈log⁡(i)⌉ times, the algorithm will be at a search index that is greater than or equal to i as 2⌈log⁡(i)⌉≥i. As such, the first stage of the algorithm takes O(log⁡i) time. The second part of the algorithm also takes O(log⁡i) time. As the second stage is simply a binary search, it takes O(log⁡n) where n is the size of the interval being searched. The size of this interval would be 2j - 2j - 1 where, as seen above, j = log⁡i. This means that the size of the interval being searched is 2log i - 2log i - 1 = 2log i - 1. This gives us a runtime of log (2log i - 1) = log (i) - 1 = O(log⁡i). This gives the algorithm a total runtime, calculated by summing the runtimes of the two stages, of O(log⁡i) + O(log⁡i) = 2 O(log⁡i) = O(log⁡i).

Alternatives Bentley and Yao suggested several variations for exponential search. These variations consist of performing a binary search, as opposed to a unary search, when determining the upper bound for the binary search in the second stage of the algorithm. This splits the first stage of the algorithm into two parts, making the algorithm a three-stage algorithm overall. The new first stage determines a value j′, much like before, such that 2j′ is larger than the search key and 2j′/2 is lower than the search key. Previously, j′ was determined in a unary fashion by calculating the next power of 2 (i.e., adding 1 to j). In the variation, it is proposed that j′ is doubled instead (e.g., jumping from 22 to 24 as opposed to 23). The first j′ such that 2j′ is greater than the search key forms a much rougher upper bound than before. Once this j′ is found, the algorithm moves to its second stage and a binary search is performed on the interval formed by j′/2 and j′, giving the more accurate upper bound exponent j. From here, the third stage of the algorithm performs the binary search on the interval 2j - 1 and 2j, as before. The performance of this variation is⌊log⁡i⌋+2⌊log⁡(⌊log⁡i⌋+1)⌋+1=O(log⁡i). Bentley and Yao generalize this variation into one where any number, k, of binary searches are performed during the first stage of the algorithm, giving the k-nested binary search variation. The asymptotic runtime does not change for the variations, running in O(log⁡i) time, as with the original exponential search algorithm. Also, a data structure with a tight version of the dynamic finger property can be given when the above result of the k-nested binary search is used on a sorted array. Using this, the number of comparisons done during a search is log (d) + log log (d) + ... + O(log *d), where d is the difference in rank between the last element that was accessed and the current element being accessed.

Applications An algorithm based on exponentially increasing the search band solves global pairwise alignment for O(ns), where n is the length of the sequences and s is the edit distance between them.

See also Linear search Binary search Interpolation search Ternary search Hash table

References

Worked examples

Example 1 — a first encounter with Exponential search

Start with the simplest possible case. Write down what Exponential search claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Exponential search before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Exponential search ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Exponential search

In research
Exponential search appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Exponential search in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Exponential search is common in secondary-school and first-year university syllabi. It links to neighbouring topics Search algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Exponential search outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Exponential search” →

How to study Exponential search in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Exponential search means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Exponential search out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Exponential search in simple terms?

In computer science, an exponential search (also called doubling search or galloping search or Struzik search) is an algorithm, created by Jon Bentley and Andrew Chi-Chih Yao in 1976, for searching sorted, unbounded/infinite lists. There are numerous ways to implement this, with the most common bei…

Why does Exponential search matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Exponential search?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Exponential search.

Tags

  • Search algorithms

Keep exploring