( The binary search algorithm can be used with only a sorted list of elements. P    ln The alternative procedure above will always return the index of the rightmost element if such an element exists. {\textstyle O(\log \log n)} Where ceil is the ceiling function, the pseudocode for this version is: The procedure may return any index whose element is equal to the target value, even if there are duplicate elements in the array. is the rank of , with the one iteration added to count the initial iteration. of the way between 6 − O It does not always return the first duplicate (consider Catholicon, a Latin dictionary finished in 1286 CE, was the first work to describe rules for sorting words into alphabetical order, as opposed to just the first few letters. R H    ) L    − If there are 1 The pointer is now on 8. n R 1 ) [55] In comparison, Grover's algorithm is the optimal quantum algorithm for searching an unordered list of elements, and it requires x However, binary search can be used to solve a wider range of problems, such as finding the next-smallest or next-largest element in the array relative to the target even if it is absent from the array. 2 , R {\displaystyle A_{0}\leq A_{1}\leq A_{2}\leq \cdots \leq A_{n-1}} Binary Search Tree: A binary search tree is a particular type of data container storing values that can provide for efficient search. 1 Universal Definition of a Binary Search Tree involves storing and search for a key based on traversing a data structure in one of two directions. ) would be 6. T A ( 1 ( nodes, which is equal to:[17], I R ) {\displaystyle n} There are specialized data structures designed for fast searching, such as hash tables, that can be searched more efficiently than binary search. ⁡ 1 n log 4 + ) ⌋ ′ {\displaystyle L