Loading AI tools
Binary search variation with simplified midpoint calculation From Wikipedia, the free encyclopedia
In computer science, multiplicative binary search is a variation of binary search that uses a specific permutation of keys in an array instead of the sorted order used by regular binary search.[1] Multiplicative binary search was first described by Thomas Standish in 1980. This algorithm was originally proposed to simplify the midpoint index calculation on small computers without efficient division or shift operations. On modern hardware, the cache-friendly nature of multiplicative binary search makes it suitable for out-of-core search on block-oriented storage as an alternative to B-trees and B+ trees. For optimal performance, the branching factor of a B-tree or B+-tree must match the block size of the file system that it is stored on. The permutation used by multiplicative binary search places the optimal number of keys in the first (root) block, regardless of block size.
This article may be too technical for most readers to understand. (September 2017) |
Class | Search algorithm |
---|---|
Data structure | Array |
Worst-case performance | O(log n) |
Best-case performance | O(1) |
Average performance | O(log n) |
Worst-case space complexity | O(1) |
Optimal | Yes |
Multiplicative binary search is used by some optimizing compilers to implement switch statements.[2][3]
Multiplicative binary search operates on a permuted sorted array. Keys are stored in the array in a level-order sequence of the corresponding balanced binary search tree. This places the first pivot of a binary search as the first element in the array. The second pivots are placed at the next two positions.
Given an array A of n elements with values A0 ... An−1, and target value T, the following subroutine uses a multiplicative binary search to find the index of T in A.
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.