Finding an element in a sorted array
Revision as of 05:52, 27 April 2016 by Weihe (talk | contribs) (Created page with "== Input == # An array <math>A</math> of some component type <math>S</math> # A definition of comparison on <math>S</math> '''Prerequisite''': The co...")
Input
- An array [math]\displaystyle{ A }[/math] of some component type [math]\displaystyle{ S }[/math]
- A definition of comparison on [math]\displaystyle{ S }[/math]
Prerequisite: The components of [math]\displaystyle{ A }[/math] are sorted in ascending order according to the comparison.
- An element [math]\displaystyle{ s\in S/math\gt == Output == If \lt math\gt s }[/math] equals at least one of the components of [math]\displaystyle{ A }[/math], the index of one of the occurrences is returned; otherwise, the information is returned that [math]\displaystyle{ s }[/math] is not in [math]\displaystyle{ A }[/math].