Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix formatting: remove extra blank lines to pass clang linter
  • Loading branch information
Mudita-Singh committed Apr 2, 2026
commit ab522e80b8c508cbd7fb4b1fa562ca8b10c59230
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public final class IterativeBinarySearch implements SearchAlgorithm {
*/
@Override
public <T extends Comparable<T>> int find(T[] array, T key) {

// Handle edge cases: null/empty array or null key
// Prevents NullPointerException during comparison
if (array == null || array.length == 0 || key == null) {
Expand All @@ -44,11 +43,9 @@ public <T extends Comparable<T>> int find(T[] array, T key) {
int right = array.length - 1;

while (left <= right) {

// Use unsigned right shift to avoid overflow
// Equivalent to (left + right) / 2 but safer for large indices
int mid = (left + right) >>> 1;

int cmp = key.compareTo(array[mid]);

if (cmp == 0) {
Expand Down
Loading