From d22420fea8d7b05d02e42111d9bc5e24137e907f Mon Sep 17 00:00:00 2001 From: vie02 Date: Wed, 7 Sep 2022 13:01:22 +0700 Subject: [PATCH] Fix off-by-one error (fixes #3248) (#3250) --- src/main/java/com/thealgorithms/searches/BinarySearch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/searches/BinarySearch.java b/src/main/java/com/thealgorithms/searches/BinarySearch.java index 22c12459..5bfe92ee 100644 --- a/src/main/java/com/thealgorithms/searches/BinarySearch.java +++ b/src/main/java/com/thealgorithms/searches/BinarySearch.java @@ -31,7 +31,7 @@ class BinarySearch implements SearchAlgorithm { */ @Override public > int find(T[] array, T key) { - return search(array, key, 0, array.length); + return search(array, key, 0, array.length - 1); } /**