Skip to content

Commit 8d9ca35

Browse files
Add edge cases section in JavaDoc for BinarySearch
1 parent f330d39 commit 8d9ca35

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main/java/com/thealgorithms/searches/BinarySearch.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222
* try - Average-case time complexity: O(log n) - Most common scenario - Worst-case time
2323
* complexity: O(log n) - Element not found or at extreme end - Space complexity: O(1) - Only uses
2424
* a constant amount of extra space
25+
*
26+
* <p><strong>Edge Cases:</strong>
27+
* <ul>
28+
* <li>Empty array: Returns -1</li>
29+
* <li>Null array: Returns -1</li>
30+
* <li>Null key: Returns -1</li>
31+
* <li>Element not found: Returns -1</li>
32+
* <li>Duplicate elements: May return any one valid index of the target</li>
33+
* </ul>
2534
*
2635
* <p>Example Walkthrough: Array: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19] Target: 7
2736
*

0 commit comments

Comments
 (0)