Content deleted Content added
Adding local short description: "Binary search variation with simplified midpoint calculation", overriding Wikidata description "search algorithm" (Shortdesc helper) |
m Fixed leq, geq operator order |
||
(5 intermediate revisions by 5 users not shown) | |||
Line 20:
On modern hardware, the [[cache (computing)|cache]]-friendly nature of multiplicative binary search makes it suitable for [[out-of-core]] search on [[Block (data storage)|block-oriented]] storage as an alternative to [[B-tree]]s and [[B+ tree]]s. 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 ([[Tree_(graph_theory)#Rooted_tree|root]]) block, regardless of block size.
Multiplicative binary search is used by some [[optimizing compiler]]s to implement [[switch statement]]s.<ref>{{cite journal |last1=Sayle|first1=Roger A. |title=A Superoptimizer Analysis of Multiway Branch Code Generation |journal=Proceedings of the GCC Developers' Summit |date=17 June 2008 |pages=103–116 |url=https://www.nextmovesoftware.com/technology/SwitchOptimization.pdf |accessdate=4 March 2017}}</ref><ref>{{cite
== Algorithm ==
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 ''A''<sub>0</sub> ... ''A''<sub>''n''−1</sub>, and target value ''T'', the following [[subroutine]] uses a multiplicative binary search to find the index of ''T'' in ''A''.
# Set ''i'' to 0
# if ''i'' ≥ ''n'', the search terminates
# if A<sub>''i''</sub> = ''T'', the search is done; return ''i''.
# if A<sub>''i''</sub>
# if A<sub>''i''</sub>
== See also ==
*
*
*
== Citations ==
|