We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9cd54ee commit b9c25a8Copy full SHA for b9c25a8
1 file changed
src/main/java/com/thealgorithms/searches/BinarySearch.java
@@ -55,6 +55,16 @@ class BinarySearch implements SearchAlgorithm {
55
* @param array The sorted array to search in (MUST be sorted in ascending order)
56
* @param key The element to search for
57
* @return The index of the key if found, -1 if not found or if array is null/empty
58
+ *
59
+ * <p><strong>Edge Cases:</strong>
60
+ * <ul>
61
+ * <li>Null array → returns -1</li>
62
+ * <li>Empty array → returns -1</li>
63
+ * <li>Null key → returns -1</li>
64
+ * <li>Element not found → returns -1</li>
65
+ * <li>Single element array → works correctly</li>
66
+ * <li>Duplicate elements → may return any one valid index</li>
67
+ * </ul>
68
*/
69
@Override
70
public <T extends Comparable<T>> int find(T[] array, T key) {
0 commit comments