mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-19 17:54:42 +08:00
docs: update the whole repository
* fix some bugs * delete duplicate files * format code
This commit is contained in:
@ -11,7 +11,7 @@ import static java.lang.String.format;
|
||||
* This class represents iterative version {@link BinarySearch}
|
||||
* Iterative binary search is likely to have lower constant factors because it doesn't involve the overhead of manipulating the call stack.
|
||||
* But in java the recursive version can be optimized by the compiler to this version.
|
||||
*
|
||||
* <p>
|
||||
* Worst-case performance O(log n)
|
||||
* Best-case performance O(1)
|
||||
* Average performance O(log n)
|
||||
@ -19,24 +19,21 @@ import static java.lang.String.format;
|
||||
*
|
||||
* @author Gabriele La Greca : https://github.com/thegabriele97
|
||||
* @author Podshivalov Nikita (https://github.com/nikitap492)
|
||||
*
|
||||
* @see SearchAlgorithm
|
||||
* @see BinarySearch
|
||||
*
|
||||
*/
|
||||
|
||||
public final class IterativeBinarySearch implements SearchAlgorithm {
|
||||
|
||||
/**
|
||||
* This method implements an iterative version of binary search algorithm
|
||||
*
|
||||
*
|
||||
* @param array a sorted array
|
||||
* @param key the key to search in array
|
||||
*
|
||||
* @param key the key to search in array
|
||||
* @return the index of key in the array or -1 if not found
|
||||
*/
|
||||
@Override
|
||||
public <T extends Comparable<T>> int find(T[] array, T key) {
|
||||
public <T extends Comparable<T>> int find(T[] array, T key) {
|
||||
int l, r, k, cmp;
|
||||
|
||||
l = 0;
|
||||
|
Reference in New Issue
Block a user